From c0d719ab78cfb2c4ea192b50ce1ddad87e7f591c Mon Sep 17 00:00:00 2001 From: Jakub Fojt Date: Tue, 3 Dec 2019 13:00:31 +0100 Subject: [PATCH] Add bash prompt and vim snakemake config --- .bash_prompt.kuba | 87 +++++++++++++++++++++++++++++++++++++++++++++++ .bashrc.kuba | 2 +- .tmux.conf | 4 +++ .vimrc | 2 +- 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 .bash_prompt.kuba diff --git a/.bash_prompt.kuba b/.bash_prompt.kuba new file mode 100644 index 0000000..46bf7e5 --- /dev/null +++ b/.bash_prompt.kuba @@ -0,0 +1,87 @@ +#!/bin/bash + +set_prompt_fancy() +{ + local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)" + + local last_cmd=$? + local txtreset='$(tput sgr0)' + local txtbold='$(tput bold)' + local txtblack='$(tput setaf 0)' + local txtred='$(tput setaf 1)' + local txtgreen='$(tput setaf 2)' + local txtyellow='$(tput setaf 3)' + local txtblue='$(tput setaf 4)' + local txtpurple='$(tput setaf 5)' + local txtcyan='$(tput setaf 6)' + local txtwhite='$(tput setaf 7)' + # unicode "✗" + local fancyx='\342\234\227' + # unicode "✓" + local checkmark='\342\234\223' + # Line 1: Full date + full time (24h) + # Line 2: current path + PS1="\[$txtbold\]\[$txtwhite\]\n\D{%A %d %B %Y %H:%M:%S}\n\[$txtgreen\]\w\n" + # Line 3: Git repo + path in repo + if [ "$is_git" ]; then + local git_repo=$(basename `git rev-parse --show-toplevel` 2>/dev/null) + local git_rel_path=$(git rev-parse --show-prefix 2>/dev/null) + PS1+="$txtcyan$git_repo $txtpurple$git_rel_path$txtreset\n" + fi + # User color: red for root, yellow for others + if [[ $EUID == 0 ]]; then + PS1+="\[$txtred\]" + else + PS1+="\[$txtyellow\]" + fi + # Line 3: user@host + PS1+="\u\[$txtwhite\]@\h\n" + # Line 4: a red "✗" or a green "✓" and the error number + if [[ $last_cmd == 0 ]]; then + PS1+="\[$txtgreen\]$checkmark \[$txtwhite\](0)" + else + PS1+="\[$txtred\]$fancyx \[$txtwhite\]($last_cmd)" + fi + # Line 4: green git branch + PS1+="\[$txtgreen\]$(__git_ps1 ' (%s)')\[$txtwhite\]" + # Line 4: good old prompt, $ for user, # for root + PS1+=" \\$ " +} + +set_prompt() +{ + local is_git="$(git rev-parse --is-inside-work-tree 2>/dev/null)" + + local txtreset='$(tput sgr0)' + local txtbold='$(tput bold)' + local txtblack='$(tput setaf 0)' + local txtred='$(tput setaf 1)' + local txtgreen='$(tput setaf 2)' + local txtyellow='$(tput setaf 3)' + local txtblue='$(tput setaf 4)' + local txtpurple='$(tput setaf 5)' + local txtcyan='$(tput setaf 6)' + local txtwhite='$(tput setaf 7)' + + # User color: red for root, yellow for others + if [[ $EUID == 0 ]]; then + PS1+="\[$txtred\]" + else + PS1+="\[$txtyellow\]" + fi + # user@host + PS1="\u\[$txtwhite\]@\h" + # Current path + PS1+="\[$txtgreen\]\w " + # Git repo + path in repo + if [ "$is_git" ]; then + local git_repo=$(basename `git rev-parse --show-toplevel` 2>/dev/null) + local git_rel_path=$(git rev-parse --show-prefix 2>/dev/null) + PS1+="$txtcyan$git_repo $txtpurple$git_rel_path$txtreset" + # Green git branch + PS1+="\[$txtgreen\]$(__git_ps1 ' (%s)')\[$txtwhite\] " + fi + # Good old prompt, $ for user, # for root + PS1+="$txtreset\\$ " +} +export PROMPT_COMMAND='set_prompt' diff --git a/.bashrc.kuba b/.bashrc.kuba index 20b64aa..a8d8f55 100755 --- a/.bashrc.kuba +++ b/.bashrc.kuba @@ -5,7 +5,7 @@ # If not running interactively, don't do anything [[ $- != *i* ]] && return alias ls='ls --color=auto' -PS1='[\u@\h \W]\$ ' +source ~/.bash_prompt.kuba export EDITOR="vim" export CUPS_GSSSERVICENAME=HTTP export PATH=$PATH:/home/kuba/bin diff --git a/.tmux.conf b/.tmux.conf index 573d1a0..df296a5 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -2,3 +2,7 @@ unbind C-b set-option -g prefix C-a bind-key C-a send-prefix set -g mouse on + +# pane movement +bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'" +bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'" diff --git a/.vimrc b/.vimrc index 97be2d0..220730a 100755 --- a/.vimrc +++ b/.vimrc @@ -23,8 +23,8 @@ if filereadable(expand(vundle_dir) . "/README.md") Plugin 'airblade/vim-gitgutter' Plugin 'jeetsukumaran/vim-pythonsense' Plugin 'easymotion/vim-easymotion' - Plugin 'file:///home/kuba/git/vim-indexer' Plugin 'cpiger/NeoDebug' + Plugin 'ivan-krukov/vim-snakemake' call vundle#end() " required else