Last active
December 18, 2015 17:29
-
-
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
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
# 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