Created
November 14, 2008 16:47
-
-
Save singpolyma/24977 to your computer and use it in GitHub Desktop.
Awesome git prompt
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
# 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