fish-shell icon indicating copy to clipboard operation
fish-shell copied to clipboard

Use `fish_color_at` to decide the colour of the @ (if present) in the prompt

Open vext01 opened this issue 2 years ago • 3 comments

Description

As discussed here, you can't easily change the colour of the @ in the prompt (if present).

This draft proposes a fix.

TODOs:

  • [ ] Discuss if this is the correct way to do it.
  • [ ] Update all themes, adding fish_color_at=normal, so that they all render the same if the user doesn't specify.
  • [ ] Do something similar for any trailing prompt character? (in the linked issue, the user can't change the colour of the >)

vext01 avatar Dec 20 '23 12:12 vext01

how about

functions -c fish_prompt default_fish_prompt
function fish_prompt
    default_fish_prompt | string replace @ (set_color red)@
end

krobelus avatar Feb 11 '24 06:02 krobelus

how about

I guess that's a workaround, but it doesn't allow individual themes to describe their desired colour.

vext01 avatar Feb 13 '24 11:02 vext01

is there any theme that wants to this to be different than $fish_color_normal? If not then we can do

diff --git a/share/functions/prompt_login.fish b/share/functions/prompt_login.fish
index 632a462bd..3ec1647fd 100644
--- a/share/functions/prompt_login.fish
+++ b/share/functions/prompt_login.fish
@@ -26,3 +26,3 @@ function prompt_login --description "display user name for the prompt"
 
-    echo -n -s (set_color $fish_color_user) "$USER" (set_color normal) @ (set_color $color_host) (prompt_hostname) (set_color normal)
+    echo -n -s (set_color $fish_color_user) "$USER" (set_color $fish_color_normal) @ (set_color $color_host) (prompt_hostname) (set_color normal)
 end

AFAICT fish_color_normal is used as fallback for syntax highlighting on text that doesn't have a distinguishing role, or for cases where the highlighting for that role has been explicitly disabled (such as set -e fish_color_command ).

I think that's a relatively obvious approach. In future we should also give prompt variables like $fish_color_user the same behavior of falling back to $fish_color_normal if unset.

krobelus avatar Mar 08 '24 06:03 krobelus

I'm closing this for now.

vext01 avatar Jul 26 '24 13:07 vext01