Skip to content

Instantly share code, notes, and snippets.

@lslucas
Created September 27, 2012 14:43
Show Gist options
  • Save lslucas/3794385 to your computer and use it in GitHub Desktop.
Save lslucas/3794385 to your computer and use it in GitHub Desktop.
Show current branch on git repo folder. Colorized
## based on http://www.developerzen.com/2011/01/10/show-the-current-git-branch-in-your-command-prompt/
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
BLUE="[\033[0;34m\]"
DARK_BLUE="[\033[1;34m\]"
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
GRAY="[\033[1;30m\]"
LIGHT_GRAY="[\033[0;37m\]"
NO_COLOUR="\[\033[0m\]"
PS1="$RED\u$NO_COLOUR@$GREEN\h$NO_COLOUR:$BLUE\w$GRAY\$(parse_git_branch)$NO_COLOUR\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment