Skip to content

Instantly share code, notes, and snippets.

@pestophagous
Created September 14, 2015 21:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pestophagous/245d6c3178c7f88c7a70 to your computer and use it in GitHub Desktop.
Save pestophagous/245d6c3178c7f88c7a70 to your computer and use it in GitHub Desktop.
put in bash .profile to see git branch name as part of PS1 prompt
# write a function to compute the current git branch
parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
} # why is the ending with the > and the extra space not working??
# set the PS1 variable
PS1="$PS1\[\e[0;33;34m\]\$(parse_git_branch)\[\e[0;0m\]"
#local BLUE="\[\033[0;34m\]"
#local RED="\[\033[0;31m\]"
#local LIGHT_RED="\[\033[1;31m\]"
#local GREEN="\[\033[0;32m\]"
#local LIGHT_GREEN="\[\033[1;32m\]"
#local WHITE="\[\033[1;37m\]"
#local RESTORE="\[\033[0;0m\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment