Created
November 13, 2014 07:29
-
-
Save mrmike/399d32748a53445f08d9 to your computer and use it in GitHub Desktop.
git settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| alias gst='git status' | |
| alias gd='git diff' | |
| alias gl='git lg' | |
| c_cyan=`tput setaf 6` | |
| c_red=`tput setaf 1` | |
| c_green=`tput setaf 2` | |
| c_light_red="$(tput setab 1)" | |
| c_sgr0=`tput sgr0` | |
| branch_color () | |
| { | |
| if git rev-parse --git-dir >/dev/null 2>&1 | |
| then | |
| color="" | |
| # check if it is smoething not pushed in submodule | |
| if (cd `git rev-parse --show-toplevel`; git submodule foreach git status) | grep "ahead" --quiet >/dev/null >&2 | |
| then | |
| color=${c_light_red} | |
| else | |
| # check if something is not commited | |
| if git status | grep "clean" --quiet 2>/dev/null >&2 | |
| then | |
| #check if something is not pushed | |
| if git status | grep "ahead" --quiet >/dev/null >&2 | |
| then | |
| color=${c_cyan} | |
| else | |
| color=${c_green} | |
| fi | |
| else | |
| color=${c_red} | |
| fi | |
| fi | |
| else | |
| return 0 | |
| fi | |
| echo -n $color | |
| } | |
| parse_git_branch () | |
| { | |
| if git rev-parse --git-dir >/dev/null 2>&1 | |
| then | |
| gitver="["$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')"]" | |
| else | |
| return 0 | |
| fi | |
| echo -e $gitver | |
| } | |
| PS1='\u@\[${c_red}\]\w\[${c_sgr0}\]\[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]$ ' | |
| # Git auto-completion | |
| if [ -f ~/.git-completion.bash ]; then | |
| . ~/.git-completion.bash | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment