Created
March 17, 2009 09:38
-
-
Save raldred/80426 to your computer and use it in GitHub Desktop.
pretty bash prompt with current working git branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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