Skip to content

Instantly share code, notes, and snippets.

@raldred
Created March 17, 2009 09:38
Show Gist options
  • Save raldred/80426 to your computer and use it in GitHub Desktop.
Save raldred/80426 to your computer and use it in GitHub Desktop.
pretty bash prompt with current working git branch
reset=$(tput sgr0)
black=$(tput setaf 0)
red=$(tput setaf 1)
green=$(tput setaf 2)
yellow=$(tput setaf 3)
blue=$(tput setaf 4)
violet=$(tput setaf 5)
cyan=$(tput setaf 6)
white=$(tput setaf 7)
parse_git_branch() {
branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'`
if [ "$branch" = "(master)" ] ; then
branch="$red${branch}$reset"
elif [ "$branch" != '' ] ; then
branch="$yellow${branch}$reset"
fi
echo $branch
}
export PS1='\[$green\]\h\[$red\]:\[$blue\]\w $(parse_git_branch)\n \[$green\]→\[$white\] '
export CLICOLOR=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment