Created
March 8, 2012 01:20
-
-
Save twasink/1997799 to your computer and use it in GitHub Desktop.
Colourised git-aware PS1 that also knows what repo you're in.
This file contains hidden or 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
__git_repo () { | |
local g="$(__gitdir)" | |
local repo_dir="" | |
if [ -n "$g" ]; then | |
if [ ! ".git" == "$g" ]; then | |
git_dir=`dirname $g` | |
repo_dir=`basename $git_dir` | |
printf " $repo_dir" | |
fi | |
fi | |
} | |
export GIT_PS1_SHOWDIRTYSTATE=1 | |
export PS1='[\[\033[0;31m\]\u@\h\[\033[0m\]\[\033[0;36 m\]$(__git_repo) \[\033[0;34m\]\W\[\033[0;35m\]$(__git_ps1 " (%s)")\[\033[0m\]]\$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I use this on my mac. You'll also need the git bash_completion stuff enabled (e.g. 'source /usr/local/git/contrib/completion/git-completion.bash')