-
-
Save vishvananda/1237345 to your computer and use it in GitHub Desktop.
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
function git_branch { | |
git branch --no-color 2> /dev/null | egrep '^\*' | sed -e 's/^* //' | |
} | |
function git_dirty { | |
# only tracks modifications, not unknown files needing adds | |
if [ -z "`git status -s | awk '{print $1}' | grep '[ADMTU]'`" ] ; then | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
function dirty_git_prompt { | |
branch=`git_branch` | |
if [ -z "${branch}" ] ; then | |
return | |
fi | |
git_dirty && echo " (${branch})" | |
} | |
function clean_git_prompt { | |
branch=`git_branch` | |
if [ -z "${branch}" ] ; then | |
return | |
fi | |
git_dirty || echo " (${branch})" | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;31m\]$(dirty_git_prompt)\[\033[01;32m\]$(clean_git_prompt)\[\033[00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w $(git_branch)\$ ' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment