mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-27 08:48:56 +01:00
perf(mercurial): improve performance of hg_prompt_info
(#7929)
Replaced two different calls of hg with one `hg --id --branch` for retrieving information whether we're in a repo (will be empty if not), whether the repo is dirty (revision id will contain "+" if there are uncommitted changed), and the branch name. Closes #6197 Closes #7929
This commit is contained in:
parent
dcf12ba8f3
commit
e52584c901
@ -35,12 +35,29 @@ function hg_get_branch_name() {
|
||||
}
|
||||
|
||||
function hg_prompt_info {
|
||||
_DISPLAY=`hg branch 2>/dev/null`
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
|
||||
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR"
|
||||
local info rev branch dirty
|
||||
|
||||
if ! info=$(hg id --id --branch 2>/dev/null); then
|
||||
return
|
||||
fi
|
||||
unset _DISPLAY
|
||||
|
||||
rev="${info[(w)1]}"
|
||||
branch="${${info[(w)2]}:gs/%/%%}"
|
||||
|
||||
if [[ "$rev" = *+ ]]; then
|
||||
dirty="$ZSH_THEME_HG_PROMPT_DIRTY"
|
||||
else
|
||||
dirty="$ZSH_THEME_HG_PROMPT_CLEAN"
|
||||
fi
|
||||
|
||||
echo "${ZSH_PROMPT_BASE_COLOR}\
|
||||
${ZSH_THEME_HG_PROMPT_PREFIX}\
|
||||
${ZSH_THEME_REPO_NAME_COLOR}\
|
||||
${branch}\
|
||||
${ZSH_PROMPT_BASE_COLOR}\
|
||||
${dirty}\
|
||||
${ZSH_THEME_HG_PROMPT_SUFFIX}\
|
||||
${ZSH_PROMPT_BASE_COLOR}"
|
||||
}
|
||||
|
||||
function hg_dirty_choose {
|
||||
|
Loading…
Reference in New Issue
Block a user