Skip to content

Instantly share code, notes, and snippets.

@twasink
Created March 8, 2012 01:20
Show Gist options
  • Save twasink/1997799 to your computer and use it in GitHub Desktop.
Save twasink/1997799 to your computer and use it in GitHub Desktop.
Colourised git-aware PS1 that also knows what repo you're in.
__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\]]\$ '
@twasink
Copy link
Author

twasink commented Mar 8, 2012

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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment