From 37e0a5ae8d708adfd98678043c4750e5d859fd57 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Mon, 13 Oct 2025 17:51:54 +0200 Subject: [PATCH] fish_config prompt save: don't define right prompt unnecessarily If no "fish_right_prompt" is defined, then we also don't need to define and save an empty one. We can do nothing, which seems cleaner. It's also what "fish_config prompt choose" does. Git blame shows no explicit reason for for this inconsistency. Probably the implicit reason is that when both styles where introduced (both in 69074c15910 (fish_config: Remove right prompt in `choose` and `save`, 2021-09-26)), that was before the "fish_config prompt choose: make right prompt hack less weird" commit, so the "prompt choose" code path didn't know whether the prompt existed until after checking, hence "--erase" was more suitable.. but that inconsistency is gone. --- share/functions/fish_config.fish | 9 +++++++-- tests/checks/fish_config.fish | 3 +-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish index 9b9252eb8..e69189d3f 100644 --- a/share/functions/fish_config.fish +++ b/share/functions/fish_config.fish @@ -130,7 +130,11 @@ function fish_config --description "Launch fish's web based configuration" funcsave fish_prompt or return - funcsave fish_right_prompt 2>/dev/null + if functions -q fish_right_prompt + funcsave fish_right_prompt + else + rm -f $__fish_config_dir/functions/fish_right_prompt.fish + end return end @@ -362,7 +366,8 @@ function __fish_config_prompt_save # if necessary. function fish_prompt end - function fish_right_prompt + if functions -q fish_right_prompt + functions --erase fish_right_prompt end source $argv[1] # N.B We're passed either stdin or argv. end diff --git a/tests/checks/fish_config.fish b/tests/checks/fish_config.fish index 6a5cda0ca..dae04bbec 100644 --- a/tests/checks/fish_config.fish +++ b/tests/checks/fish_config.fish @@ -43,8 +43,7 @@ echo yes | fish_config prompt save nim >/dev/null grep -q nim@Hattori $__fish_config_dir/functions/fish_prompt.fish || echo 'failed to save prompt?' cat $__fish_config_dir/functions/fish_right_prompt.fish -# CHECK: function fish_right_prompt -# CHECK: end +# CHECKERR: cat: {{.*}}/functions/fish_right_prompt.fish: No such file or directory cat $__fish_config_dir/functions/fish_mode_prompt.fish # CHECKERR: cat: {{.*}}/functions/fish_mode_prompt.fish: No such file or directory