Skip to content

Instantly share code, notes, and snippets.

@botandrose
Created April 25, 2014 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save botandrose/11303438 to your computer and use it in GitHub Desktop.
Save botandrose/11303438 to your computer and use it in GitHub Desktop.
git prompt
# shove this in your .bashrc or .bash_profile or whatever
function parse_git_dirty {
[[ $(git ls-files -o -m --exclude-standard 2> /dev/null) != "" ]] && echo "*"
}
function parse_git_branch {
if type -p __git_ps1; then
branch=$(__git_ps1 '%s')
if [ -n "$branch" ]; then
echo -e "[$branch]"
fi
fi
}
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;32m\]$(parse_git_branch)\[\033[1;31m\]$(parse_git_dirty)\[\033[00m\]\$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment