Created
May 24, 2009 14:46
-
-
Save davidcotter/117129 to your computer and use it in GitHub Desktop.
Git branch in bash 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
# Git branch in bash prompt | |
# At the top of .bashrc | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
function prompt_with_git_branch { | |
case $TERM in | |
xterm*) | |
TITLEBAR='\[\033]0;\u@\h:\w\007\]' | |
;; | |
*) | |
TITLEBAR="" | |
;; | |
esac | |
PS1="${TITLEBAR}\ | |
\u@\h:\w\$(parse_git_branch)\$ " | |
PS2='> ' | |
PS4='+ ' | |
} | |
# At the bottom of .bashrc (so ot supercedes any other prompt stuff) | |
prompt_with_git_branch | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment