Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vext01
Copy link

@vext01 vext01 commented Dec 20, 2023

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 >)

@krobelus
Copy link
Member

how about

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

@henrikhorluck henrikhorluck marked this pull request as ready for review February 11, 2024 16:21
@henrikhorluck henrikhorluck marked this pull request as draft February 11, 2024 16:22
@vext01
Copy link
Author

vext01 commented Feb 13, 2024

how about

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

@krobelus
Copy link
Member

krobelus commented Mar 8, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants