mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-09 02:24:03 +01:00
added hg,zsh to library for prompt
This commit is contained in:
parent
6d7a275972
commit
4a1c09d988
1 changed files with 32 additions and 0 deletions
32
lib/hg.zsh
Normal file
32
lib/hg.zsh
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# get the name of the branch we are on
|
||||||
|
function hg_prompt_info() {
|
||||||
|
ref=$(hg branch 2> /dev/null) || return
|
||||||
|
echo "$ZSH_THEME_HG_PROMPT_PREFIX${ref}$(hg_prompt_status)$(parse_hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX"
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_hg_dirty () {
|
||||||
|
if [[ -n $(hg status 2> /dev/null) ]]; then
|
||||||
|
echo "$ZSH_THEME_HG_PROMPT_DIRTY"
|
||||||
|
else
|
||||||
|
echo "$ZSH_THEME_HG_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_HG_PROMPT_UNTRACKED$STATUS"
|
||||||
|
fi
|
||||||
|
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
|
||||||
|
STATUS="$ZSH_THEME_HG_PROMPT_ADDED$STATUS"
|
||||||
|
fi
|
||||||
|
if $(echo "$INDEX" | grep '^M ' &> /dev/null); then
|
||||||
|
STATUS="$ZSH_THEME_HG_PROMPT_MODIFIED$STATUS"
|
||||||
|
fi
|
||||||
|
if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
|
||||||
|
STATUS="$ZSH_THEME_HG_PROMPT_DELETED$STATUS"
|
||||||
|
fi
|
||||||
|
echo $STATUS
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue