Created
March 29, 2011 16:18
-
-
Save andreapavoni/892659 to your computer and use it in GitHub Desktop.
my custom colored bash prompt with current git branch status
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
# git dirty bash prompt (mostly ripped from http://henrik.nyh.se/2008/12/git-dirty-prompt) | |
# clean repo: | |
# user@host:~/path/to/repo/ [current-branch]$ | |
# dirty repo: | |
# user@host:~/path/to/repo/ [current-branch*]$ | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" | |
} | |
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[0;33m\] $(parse_git_branch)\[\033[00m\]$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment