Last active
May 25, 2018 05:18
-
-
Save echorohit/955c0457089f3e65767db080a006160c to your computer and use it in GitHub Desktop.
.bashrc
This file contains 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
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi | |
rohitchoudhary@~$ cat ~/.bashrc | |
export NVM_DIR="/Users/rohitchoudhary/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm | |
source /usr/local/etc/bash_completion.d/git-completion.bash | |
source /usr/local/etc/bash_completion.d/git-prompt.sh | |
GIT_PS1_SHOWDIRTYSTATE=true | |
# Setting GIT prompt | |
c_cyan=`tput setaf 6` | |
c_red=`tput setaf 1` | |
c_green=`tput setaf 2` | |
c_sgr0=`tput sgr0` | |
branch_color () | |
{ | |
if git rev-parse --git-dir >/dev/null 2>&1 | |
then | |
color="" | |
if git diff --quiet 2>/dev/null >&2 | |
then | |
color=${c_green} | |
else | |
color=${c_red} | |
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 | |
} | |
#It's important to escape colors with \[ to indicate the length is 0 | |
PS1='\u@\[${c_red}\]\W\[${c_sgr0}\]\[\[$(branch_color)\]$(parse_git_branch)\[${c_sgr0}\]$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment