Permalink
Browse files

Adding support back for zsh < 4.3.6

  • Loading branch information...
1 parent 8dc6dfa commit 00f0623dd121749c4aa13b887b65c3af0dcb43cd @mattfoster committed Feb 1, 2009
Showing with 41 additions and 29 deletions.
  1. +1 −1 01_path
  2. +32 −24 06_git
  3. +7 −3 10_hooks
  4. +1 −1 func/prompt_minimal_vcs_setup
View
@@ -15,7 +15,7 @@ for dir ($pathdirs)
cdpath=(~ ~/Projects)
# Allow MacPorts man pages and others
-dirs=( /usr/local/git/man /sw/share/man /opt/local/man )
+dirs=( /usr/local/git/man /sw/share/man /opt/local/man /usr/local/man)
for dir ($dirs)
if [[ -x $dir ]]; then
manpath=($manpath $dir)
View
@@ -3,9 +3,18 @@ if [[ -x `which git` ]]; then
function git-branch-name () {
git branch 2> /dev/null | grep '^\*' | sed 's/^\*\ //'
}
+ # Return 1 if repository is dirty. 0 if it isn't a repostory, or is clean.
function git-dirty () {
- git status 2> /dev/null | grep "nothing to commit (working directory clean)"
- echo $?
+ local code
+ gs=$(git status 2> /dev/null)
+ if [[ $? == 128 ]];
+ then
+ code=0
+ else
+ echo $gs | grep "nothing to commit (working directory clean)" | 2>&1 > /dev/null
+ code=$?
+ fi
+ echo $code
}
function gsrb () {
branch=$(git-branch-name)
@@ -23,27 +32,27 @@ if [[ -x `which git` ]]; then
fi
}
- # function git-prompt() {
- # emulate -L zsh
- # dirty_color=$fg[cyan]
- # branch=$(echo $gstatus | head -n 1 | sed 's/^# On branch //')
- # if [[ $branch == '# Not currently on any branch.' ]]; then
- # no_branch=1
- # branch='none'
- # fi
- # if [[ $git_enable = 1 ]]; then
- # gstatus=$(git status 2> /dev/null)
- # branch=$(echo $gstatus | head -n 1 | sed 's/^# On branch //')
- # dirty=$(echo $gstatus | sed 's/^#.*$//' | tail -n 2 | grep 'nothing to commit (working directory clean)'; echo $?)
- # if [[ x$branch != x ]]; then
- # if [[ $dirty = 1 ]] { dirty_color=$fg[magenta] }
- # if [[ $no_branch = 1 ]] { dirty_color=$fg[red] }
- # [ x$branch != x ] && echo "%{$dirty_color%}$branch%{$reset_color%} "
- # fi
- # else
- # echo "%{$dirty_color%}!%{$reset_color%}"
- # fi
- # }
+ function git-prompt() {
+ emulate -L zsh
+ dirty_color=$fg[cyan]
+ branch=$(echo $gstatus | head -n 1 | sed 's/^# On branch //')
+ if [[ $branch == '# Not currently on any branch.' ]]; then
+ no_branch=1
+ branch='none'
+ fi
+ if [[ $git_enable = 1 ]]; then
+ gstatus=$(git status 2> /dev/null)
+ branch=$(echo $gstatus | head -n 1 | sed 's/^# On branch //')
+ dirty=$(echo $gstatus | sed 's/^#.*$//' | tail -n 2 | grep 'nothing to commit (working directory clean)'; echo $?)
+ if [[ x$branch != x ]]; then
+ if [[ $dirty = 1 ]] { dirty_color=$fg[magenta] }
+ if [[ $no_branch = 1 ]] { dirty_color=$fg[red] }
+ [ x$branch != x ] && echo "%{$dirty_color%}$branch%{$reset_color%} "
+ fi
+ else
+ echo "%{$dirty_color%}!%{$reset_color%}"
+ fi
+ }
function git-scoreboard () {
git log | grep Author | sort | uniq -ci | sort -r
@@ -72,7 +81,6 @@ if [[ -x `which git` ]]; then
nohup gitk --all &
}
-
alias g='git'
alias gb='git branch -a -v'
alias gs='git status'
View
@@ -23,11 +23,15 @@ function title() {
# precmd is called just before the prompt is printed
function precmd() {
# This may not be the best way of doing this.
- if [[ $git_enable == 1 ]]; then
+ if [[ $ZSH_VERSION < 4.3.6 ]]
+ then
+ vcs_info_msg_0_=$(git-prompt)
+ elif [[ $git_enable == 1 ]]
+ then
vcs_info
else
vcs_info_msg_0_=''
- fi
+ fi
# This loads the info messgage into %1v.
title "zsh" "$USER@%m" "%55<...<%~"
}
@@ -62,4 +66,4 @@ function preexec() {
# done
# cd -q "$DIRECTORY"
# }
-# fi
+# fi
@@ -20,7 +20,7 @@ function prompt_minimal_vcs_setup {
n_tru=${3:-'blue'}
n_fal=${4:-'red'}
# I've no idea why the %F style colours don't work whhen SHLVL == 1
- if [[ $SHLVL == 1 ]]; then
+ if [[ $SHLVL == 1 || $ZSH_VERSION < 4.3.6 ]]; then
PS1='%{$fg_bold[$d_col]%}%1~ %{$fg_bold[$b_col]%}${vcs_info_msg_0_}%(?.%{$fg_bold[$n_tru]%}.%{$fg[$n_fal]%})%# %{$reset_color%}'
PS2='%_ %{$fg_bold[$d_col]%}-> %{$reset_color%}'
else

0 comments on commit 00f0623

Please sign in to comment.