From da7b762f4adb0341cea53e759965cac9c3b2e375 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 7 Mar 2020 13:01:03 +0100 Subject: [PATCH] Make default hg prompt leaner The default hg prompt is slow on large repositories (hg status takes 2-3 seconds on mozilla-central) which is unacceptable as a default. Mimick our git prompt: by default, only show the current branch. If the new variable $fish_prompt_hg_show_informative_status is set, then use the old behavior. [ci skip] --- doc_src/cmds/fish_hg_prompt.rst | 7 ++++++- share/functions/fish_hg_prompt.fish | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc_src/cmds/fish_hg_prompt.rst b/doc_src/cmds/fish_hg_prompt.rst index 06cbea5ef..3d822bfe1 100644 --- a/doc_src/cmds/fish_hg_prompt.rst +++ b/doc_src/cmds/fish_hg_prompt.rst @@ -19,7 +19,11 @@ The fish_hg_prompt function displays information about the current Mercurial rep `Mercurial `_ (``hg``) must be installed. -There are numerous customization options, which can be controlled with fish variables. +By default, only the current branch is shown because ``hg status`` can take be slow on large repository. You can enable a more informative prompt by setting the variable ``$fish_prompt_hg_show_informative_status``, for example:: + + set --universal fish_prompt_hg_show_informative_status + +If you enabled the informative status, there are numerous customization options, which can be controlled with fish variables. - ``$fish_color_hg_clean``, ``$fish_color_hg_modified`` and ``$fish_color_hg_dirty`` are colors used when the repository has the respective status. @@ -52,6 +56,7 @@ A simple prompt that displays hg info:: function fish_prompt ... + set -g fish_prompt_hg_show_informative_status printf '%s %s$' $PWD (fish_hg_prompt) end diff --git a/share/functions/fish_hg_prompt.fish b/share/functions/fish_hg_prompt.fish index 8911fbfdc..d0131bced 100644 --- a/share/functions/fish_hg_prompt.fish +++ b/share/functions/fish_hg_prompt.fish @@ -36,6 +36,12 @@ function fish_hg_prompt --description 'Write out the hg prompt' set branch "$branch|$bookmark" end + if not set -q fish_prompt_hg_show_informative_status + set_color normal + echo -n " ($branch)" + return + end + echo -n '|' # Disabling color and pager is always a good idea.