From 433d5ced97957ef2358c0c8f607abb94586449ed Mon Sep 17 00:00:00 2001 From: Peeyush Kushwaha Date: Tue, 27 Oct 2020 18:06:24 +0530 Subject: [PATCH 1/2] disable informative status by default Improves performance. Informative status config should be left upto user. See https://github.com/fish-shell/fish-shell/issues/7367#issuecomment-702596671 --- fish_prompt.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index 1aacc54..f71b2c2 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -25,7 +25,7 @@ function fish_prompt set -l bwhite (set_color -o white) # Configure __fish_git_prompt - set -g __fish_git_prompt_show_informative_status true + set -g __fish_git_prompt_use_informative_chars true set -g __fish_git_prompt_showcolorhints true # Color prompt char red for non-zero exit status From c92fc107b0aa80e3da5ec4135f84a887af83a464 Mon Sep 17 00:00:00 2001 From: Peeyush Kushwaha Date: Tue, 27 Oct 2020 18:50:22 +0530 Subject: [PATCH 2/2] auto-resize prompt based on $COLUMNS code used to reside in my config, this is a way neater re-implementation --- fish_prompt.fish | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/fish_prompt.fish b/fish_prompt.fish index f71b2c2..0100725 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -15,6 +15,7 @@ function fish_prompt end end + # Setup colors set -l normal (set_color normal) set -l cyan (set_color cyan) @@ -34,12 +35,23 @@ function fish_prompt set pcolor $bred end - # Top - echo -n $cyan$USER$normal at $yellow$__fish_prompt_hostname$normal in $bred(prompt_pwd)$normal - __fish_git_prompt + # pieces of the prompt + set -l p_user $USER + set -l p_host $__fish_prompt_hostname + set -l p_pwd (prompt_pwd) + set -l p_git (__fish_git_prompt | sed -e 's/^[[:space:]]*//') # remove leading space https://stackoverflow.com/a/3232433/1412255 - echo + set -l full_length (string length "$p_user at $p_host in $p_pwd $p_git") + set -l med_length (string length "$p_pwd $p_git") + if test $COLUMNS -gt $full_length + # Top + echo -n $cyan$p_user$normal at $yellow$p_host$normal in $bred$p_pwd$normal $p_git + echo + else if test $COLUMNS -gt $med_length + echo -n $bred$p_pwd$normal $p_git + echo + end # Bottom echo -n $pcolor$__fish_prompt_char $normal end