Skip to content

Instantly share code, notes, and snippets.

@rustygeldmacher
Created October 31, 2011 13:56
Show Gist options
  • Save rustygeldmacher/1327546 to your computer and use it in GitHub Desktop.
Save rustygeldmacher/1327546 to your computer and use it in GitHub Desktop.
Show the current git branch in your prompt (based on http://www.jonmaddox.com/2008/03/13/show-your-git-branch-name-in-your-prompt/)
function get_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/'
}
function gitify_prompt {
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
PS1="\h:\W$WHITE\$(get_git_branch)$LIGHT_GRAY\$ "
PS2='> '
PS4='+ '
}
gitify_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment