Skip to content

Instantly share code, notes, and snippets.

@singpolyma
Created November 14, 2008 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save singpolyma/24977 to your computer and use it in GitHub Desktop.
Save singpolyma/24977 to your computer and use it in GitHub Desktop.
Awesome git prompt
# Determine if the current directory is a GIT repo
# and print out '*' if there are changes to be committed
iz_git_dirty() {
#IZ_GIT=`git status 2>/dev/null`
IZ_DIRTY=`git status 2>/dev/null | grep 'nothing to commit (working directory clean)'`
#if [ "." != "$IZ_GIT." ]; then
if [ "." == "$IZ_DIRTY." ]; then
echo '*'
fi
#fi
}
# Determine if the current directory is a GIT repo
# and print out the current branch name (and call iz_git_dirty)
parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ "." != "$BRANCH." ]; then
echo "(${BRANCH}$(iz_git_dirty))"
fi
}
# Put the above stuff into the prompt
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(parse_git_branch)\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment