Skip to content

Instantly share code, notes, and snippets.

@granth
Created June 2, 2011 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save granth/1005312 to your computer and use it in GitHub Desktop.
Save granth/1005312 to your computer and use it in GitHub Desktop.
git prompt
export PS1='\[\033]0;\w\007\[\033[0;32m\]\W\[\033[0;38m\] $(git_branch)$(prompt_status "%s") '
prompt_status() {
local branch=$(__git_ps1 "%s")
if [ -n "$branch" ]; then
if git_dirty; then
echo "⚡"
return
fi
fi
echo "→"
}
git_branch() {
local branch=$(__git_ps1 "%s")
if [ -n "$branch" ]; then
if [[ ! $(git config homedir.repo) ]]; then
echo -n "$branch"
fi
fi
}
git_dirty() {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment