mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-27 03:14:56 +01:00
The added library parses output of the hg (mercurial) command, and outputs the same variables (which should be customized by theme) in your prompt. I added an example of these variables to michelebologna theme. This patch should uniform all the behaviour of all themes regarding mercurial. In fact, some themes implement their own hg parsing *inside* the theme. This should be better implemented in a library, as happens with git library.
32 lines
976 B
Bash
32 lines
976 B
Bash
# Michele Bologna
|
|
#
|
|
# Implements a hg_prompt_info function that inspect the current mercurial repo
|
|
# (if any) and then outputs the status of the repo, in a similar way with
|
|
# git.zsh library.
|
|
#
|
|
# themes should customize:
|
|
# * ZSH_THEME_HG_PROMPT_UNTRACKED - symbol to show in prompt if untracked
|
|
# files are present in the mercurial repo
|
|
# * ZSH_THEME_HG_PROMPT_ADDED - symbol to show in prompt if added files are
|
|
# present in the mercurial repo
|
|
# * ZSH_THEME_HG_PROMPT_MODIFIED - symbol to show in prompt if modified files
|
|
# are present in the mercurial repo
|
|
|
|
hg_prompt_info()
|
|
{
|
|
local STATUS=""
|
|
if $(hg id >/dev/null 2>&1); then
|
|
local BRANCH=$(hg branch 2>/dev/null)
|
|
if `hg status | grep -q "^\?"`; then
|
|
STATUS="$ZSH_THEME_HG_PROMPT_UNTRACKED"
|
|
fi
|
|
if `hg status | grep -q "^[A]"`; then
|
|
STATUS="$ZSH_THEME_HG_PROMPT_ADDED$STATUS"
|
|
fi
|
|
if `hg status | grep -q "^[M]"`; then
|
|
STATUS="$ZSH_THEME_HG_PROMPT_MODIFIED$STATUS"
|
|
fi
|
|
echo "$BRANCH$STATUS"
|
|
fi
|
|
}
|
|
|