Skip to content

Instantly share code, notes, and snippets.

@salverde
Last active October 9, 2015 18:48
Show Gist options
  • Save salverde/3559536 to your computer and use it in GitHub Desktop.
Save salverde/3559536 to your computer and use it in GitHub Desktop.
Display Git branch shell prompt & Autocomplete
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# set the PS1 variable
#PS1="\w\[\e[0;33;49m\]\$(parse_git_branch)\[\e[0;0m\]$ "
PS1="\w\[\e[0;37m\]\$(parse_git_branch)\[\e[0;0m\]$ "
# Set git autocompletion and PS1 integration
if [ -f /usr/local/Cellar/git/2.1.3/etc/bash_completion.d/git-completion.bash ]; then
. /usr/local/Cellar/git/2.1.3/etc/bash_completion.d/git-completion.bash
fi
GIT_PS1_SHOWDIRTYSTATE=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment