From 6aade380c1abc28414e98c60fe06c112447d7fe9 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 25 Apr 2021 09:49:18 +0200 Subject: [PATCH] Sample prompts: Handle print_pipestatus if TERM=dumb This is the simple solution of just quoting it. The real solution would probably handle `set_color` with no color better - #5443. Fixes #7904. --- share/functions/fish_prompt.fish | 4 +++- share/tools/web_config/sample_prompts/default.fish | 4 +++- share/tools/web_config/sample_prompts/informative.fish | 5 +++-- share/tools/web_config/sample_prompts/informative_vcs.fish | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/share/functions/fish_prompt.fish b/share/functions/fish_prompt.fish index 2e04d6688..e670991d2 100644 --- a/share/functions/fish_prompt.fish +++ b/share/functions/fish_prompt.fish @@ -30,7 +30,9 @@ function fish_prompt --description 'Write out the prompt' set bold_flag end set __fish_prompt_status_generation $status_generation - set -l prompt_status (__fish_print_pipestatus "[" "]" "|" (set_color $fish_color_status) (set_color $bold_flag $fish_color_status) $last_pipestatus) + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color $bold_flag $fish_color_status) + set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $color_host) (prompt_hostname) $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " " end diff --git a/share/tools/web_config/sample_prompts/default.fish b/share/tools/web_config/sample_prompts/default.fish index 2e04d6688..e670991d2 100644 --- a/share/tools/web_config/sample_prompts/default.fish +++ b/share/tools/web_config/sample_prompts/default.fish @@ -30,7 +30,9 @@ function fish_prompt --description 'Write out the prompt' set bold_flag end set __fish_prompt_status_generation $status_generation - set -l prompt_status (__fish_print_pipestatus "[" "]" "|" (set_color $fish_color_status) (set_color $bold_flag $fish_color_status) $last_pipestatus) + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color $bold_flag $fish_color_status) + set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) echo -n -s (set_color $fish_color_user) "$USER" $normal @ (set_color $color_host) (prompt_hostname) $normal ' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " " end diff --git a/share/tools/web_config/sample_prompts/informative.fish b/share/tools/web_config/sample_prompts/informative.fish index 1163a7f5a..3fda5801c 100644 --- a/share/tools/web_config/sample_prompts/informative.fish +++ b/share/tools/web_config/sample_prompts/informative.fish @@ -12,8 +12,9 @@ function fish_prompt --description 'Informative prompt' or set_color $fish_color_cwd) \ (prompt_pwd) (set_color normal) else - set -l pipestatus_string (__fish_print_pipestatus "[" "]" "|" (set_color $fish_color_status) \ - (set_color --bold $fish_color_status) $last_pipestatus) + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color --bold $fish_color_status) + set -l pipestatus_string (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) printf '[%s] %s%s@%s %s%s %s%s%s \n> ' (date "+%H:%M:%S") (set_color brblue) \ $USER (prompt_hostname) (set_color $fish_color_cwd) $PWD $pipestatus_string \ diff --git a/share/tools/web_config/sample_prompts/informative_vcs.fish b/share/tools/web_config/sample_prompts/informative_vcs.fish index 443fbef8f..daad7eac5 100644 --- a/share/tools/web_config/sample_prompts/informative_vcs.fish +++ b/share/tools/web_config/sample_prompts/informative_vcs.fish @@ -54,8 +54,10 @@ function fish_prompt --description 'Write out the prompt' printf '%s ' (fish_vcs_prompt) - set -l pipestatus_string (__fish_print_pipestatus "[" "]" "|" (set_color $fish_color_status) (set_color --bold $fish_color_status) $last_pipestatus) - echo -n $pipestatus_string + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color --bold $fish_color_status) + set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) + echo -n $prompt_status set_color normal echo -n "$suffix "