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

The “╭─'” prompt can be too dark #28

Open
alexislefebvre opened this issue Dec 31, 2023 · 1 comment
Open

The “╭─'” prompt can be too dark #28

alexislefebvre opened this issue Dec 31, 2023 · 1 comment

Comments

@alexislefebvre
Copy link

alexislefebvre commented Dec 31, 2023

I use the dark GNOME theme in gnome-terminal.

Capture d’écran du 2023-12-31 20-12-11

Lines 1 and 2 use the default theme, so hostcolor is used:

set -l hostcolor (set_color (uname -n | md5sum | cut -f1 -d' ' | tr -d '\n' | tail -c6))

As you can see on the screenshot, the name of the machine is “serveur”, and it causes the issue.

The colour of the prompt is the same as the result of this command:

echo "serveur" | md5sum | cut -f1 -d' ' | tr -d '\n' | tail -c6
1d410f

Lines 3 and 4 use a patch

I forced the colour on this environment:

diff --git a/functions/fish_prompt.fish b/functions/fish_prompt.fish
index 68b8125..7de249f 100644
--- a/functions/fish_prompt.fish
+++ b/functions/fish_prompt.fish
@@ -16,7 +16,7 @@ function fish_prompt
   end
 
   # Setup colors
-  set -l hostcolor (set_color (uname -n | md5sum | cut -f1 -d' ' | tr -d '\n' | tail -c6))
+  set -l hostcolor (set_color 803080)

Proposals

I don't have any idea to solve this, hostcolor may only use a color than is not too light or dark. Or a background may be used so that the prompt always have some contrast.

@davidbstein
Copy link
Contributor

A quick and dirty fix would be to replace the 0, 1, and 2s with 3s...

set -l hostcolor (set_color (uname -n | md5sum | cut -f1 -d' ' | tr -d '\n' | tail -c6 | sed 's/[0-2]/3/g'))

but that would change the color of some servers, which might cause some users of the theme to worry they're on the wrong server.

A more heavyweight solution that would retain the same unique colors currently assigned to each server would be to check for dark colors and brighten them.

set -l _hostcolor_rgb (uname -n | md5sum | cut -f1 -d' ' | tr -d '\n' | tail -c6 | sed 's/\([0-9a-f][0-9a-f]\)/0x\1 /g')
set -l _hostcolor_value ''
if test (math (string replace -a " 0x" " + 0x" $_hostcolor_rgb) ) -le (math 0x99) # true when darker than #333333
  for _color in (string split " " (string trim $_hostcolor_rgb))
    set _hostcolor_value "$_hostcolor_value"(math -b16 0x33 + $_color | sed 's/0x//g' | sed 's/[0-9a-f][0-9a-f][0-9a-f]/ff/g')
  end
else
  set _hostcolor_value (echo $_hostcolor_rgb | sed 's/\(0x\| \)//g')
end
set -l hostcolor (set_color $_hostcolor_value)

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

No branches or pull requests

2 participants