Created
April 27, 2009 02:25
-
-
Save theory/102291 to your computer and use it in GitHub Desktop.
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 function from http://github.com/bkerley/zshkit/raw/master/06_git. | |
autoload -Uz colors | |
colors | |
if [[ -x `which git` ]]; then | |
function git-prompt() { | |
gstatus=$(git status 2> /dev/null) | |
branch=$(echo $gstatus | head -1 | sed 's/^# On branch //') | |
dirty=$(echo $gstatus | sed 's/^#.*$//' | tail -2 | grep 'nothing to commit (working directory clean)'; echo $?) | |
if [[ x$branch != x ]]; then | |
dirty_color=$fg[cyan] | |
if [[ $dirty = 1 ]] { dirty_color=$fg[magenta] } | |
[ x$branch != x ] && echo " %{$dirty_color%}$branch%{$reset_color%} " | |
fi | |
} | |
else | |
function git-prompt() { | |
echo '' | |
} | |
fi | |
setopt prompt_subst | |
PROMPT='%{$reset_color%}%m %~`git-prompt`%(!.#.>) ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment