Created
February 8, 2015 17:12
-
-
Save Hiteshm01/b1a189259a0bb75d7dc1 to your computer and use it in GitHub Desktop.
git branch name in bashrc
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
red=$(tput setaf 1) | |
green=$(tput setaf 2) | |
yellow=$(tput setaf 3) | |
blue=$(tput setaf 4) | |
bold=$(tput bold) | |
reset=$(tput sgr0) | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != 'nothing to commit (working directory clean)' ]] && echo $red || echo $green | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/\* \(.*\)/\1/" | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1="\[$bold\]\[$yellow\]\h\[$reset\]:\[$bold\]\[$blue\]\w\[$reset\]:\[\$(parse_git_dirty)\]\$(parse_git_branch)\[\$reset\]\$ " | |
else | |
PS1='\u@\h:\W:$(parse_git_branch) " (%s)")\$ ' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment