Skip to content

Instantly share code, notes, and snippets.

@edwardabraham
Last active December 18, 2015 17:29
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 edwardabraham/5819287 to your computer and use it in GitHub Desktop.
Save edwardabraham/5819287 to your computer and use it in GitHub Desktop.
A git aware bash prompt for ubuntu, that shows what branch you are on, and whether you have anything to commit. Add to your .bashrc file. Works with git version 1.7.9.5. Initially taken from http://www.intridea.com/blog/2009/2/2/git-status-in-your-prompt
# A git aware bash prompt for ubuntu, that shows what branch you are on, and whether you have anything to commit.
# Add to your .bashrc file.
# Works with git version 1.7.9.5.
#
# Based on http://www.intridea.com/blog/2009/2/2/git-status-in-your-prompt
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='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]$(parse_git_branch)$ '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment