Skip to content

Instantly share code, notes, and snippets.

@alexcabrera
Created September 11, 2012 14:18
Show Gist options
  • Select an option

  • Save alexcabrera/3698938 to your computer and use it in GitHub Desktop.

Select an option

Save alexcabrera/3698938 to your computer and use it in GitHub Desktop.
Fancy 2-line bash prompt with git branch name
# Prompt Colors
prompt_purple=$(tput setaf 5)
prompt_cyan=$(tput setaf 6)
prompt_yellow=$(tput bold ; tput setaf 3)
prompt_green=$(tput setaf 2)
prompt_reset=$(tput sgr0)
# Display git branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
}
export PS1='\[$prompt_purple\]\u\[$prompt_cyan\]@\H \[$prompt_yellow\]\w$(parse_git_branch)\n\[$prompt_green\]→\[$prompt_reset\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment