From d81d822306aad05e2f15cd27065e5673f167f9f7 Mon Sep 17 00:00:00 2001 From: Romain Failliot Date: Sun, 18 Feb 2018 19:21:09 -0500 Subject: [PATCH] Add SHOW_DIRTY_BRANCH option This option is enabled by default (so that there's no regression). It simply allows to enable/disable the dirty text in the prompt. This is because in huge repositories, like the one I work with, asking for the status can take several hundreds of milliseconds. This is a not so intrusive way of providing an option in this case. --- plugins/mercurial/mercurial.plugin.zsh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index 2b0d212d..820fd7ba 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -18,6 +18,10 @@ alias hgca='hg commit --amend' # list unresolved files (since hg does not list unmerged files in the status command) alias hgun='hg resolve --list' +# Comment this line if you don't want to show if the branch is dirty or not. +# This can save a lot of time of very large repositories. +SHOW_DIRTY_BRANCH=1 + function hg_get_dir() { # Defines path as current directory local current_dir=$PWD @@ -62,7 +66,10 @@ function hg_get_branch_name() { function hg_prompt_info { local branch=$(hg_get_branch_name) if [[ $branch != "" ]]; then - echo "$ZSH_THEME_HG_PROMPT_PREFIX${branch}$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX" + if [[ $SHOW_DIRTY_BRANCH == 1 ]]; then + branch="${branch}$(hg_dirty)" + fi + echo "$ZSH_THEME_HG_PROMPT_PREFIX${branch}$ZSH_THEME_HG_PROMPT_SUFFIX" fi }