Use a vcs library and add a Mercurial plugin

Move git_* functions to vcs_* to allow for better plugin support
Modify plugins to use the new function names and declare new variable
names, so ZSH_THEME_GIT_* variables are ZSH_THEME_VCS_* and
git_prompt_info() is vcs_prompt_info()
This commit is contained in:
Jared Hancock 2011-04-07 22:59:01 -05:00
commit 753646e458
64 changed files with 370 additions and 295 deletions

40
plugins/hg/hg.plugin.zsh Normal file
View file

@ -0,0 +1,40 @@
# get the name of the branch we are on
VCS+="hg"
function hg_check() {
hg status -n > /dev/null 2>&1
return $?
}
function hg_prompt_info() {
ref=$(hg branch 2> /dev/null) || return
echo "${(e)ZSH_THEME_VCS_PROMPT_PREFIX}${ref}$(parse_hg_dirty)$ZSH_THEME_VCS_PROMPT_SUFFIX"
}
parse_hg_dirty () {
if [[ -n $(hg status -s 2> /dev/null) ]]; then
echo "$ZSH_THEME_VCS_PROMPT_DIRTY"
else
echo "$ZSH_THEME_VCS_PROMPT_CLEAN"
fi
}
# get the status of the working tree
hg_prompt_status() {
INDEX=$(hg status 2> /dev/null)
STATUS=""
if $(echo "$INDEX" | grep '^? ' &> /dev/null); then
STATUS="$ZSH_THEME_VCS_PROMPT_UNTRACKED$STATUS"
fi
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
STATUS="$ZSH_THEME_VCS_PROMPT_ADDED$STATUS"
fi
if $(echo "$INDEX" | grep '^M ' &> /dev/null); then
STATUS="$ZSH_THEME_VCS_PROMPT_MODIFIED$STATUS"
fi
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
STATUS="$ZSH_THEME_VCS_PROMPT_DELETED$STATUS"
fi
echo $STATUS
}