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]
This commit is contained in:
Johannes Altmanninger 2020-03-07 13:01:03 +01:00
parent 6f22aadaf7
commit da7b762f4a
2 changed files with 12 additions and 1 deletions

View File

@ -19,7 +19,11 @@ The fish_hg_prompt function displays information about the current Mercurial rep
`Mercurial <https://www.mercurial-scm.org/>`_ (``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

View File

@ -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.