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

How to change the current selection's highlight color in zsh? #2419

Closed
ritiek opened this issue Mar 8, 2020 · 9 comments
Closed

How to change the current selection's highlight color in zsh? #2419

ritiek opened this issue Mar 8, 2020 · 9 comments

Comments

@ritiek
Copy link

ritiek commented Mar 8, 2020

Hi, and thanks for making Kitty!

Kitty seems to be using black foreground color for highlightning selected items when using zsh's tab auto-complete. This makes it really hard to read the text for current selection on dark backgrounds.

For example this gif, when hitting tab key in zsh for listing and selecting files in current directory:

kitty


However, when using gnome-terminal and doing the same, the selected file is highlighted with a white background and a black foreground:

gterm

which is easier to read.


Is it possible to change this black foregound highlight color in Kitty to something else?

I've tried setting the values for selection_foreground and selection_background but they seem to only affect colors for selections made using a mouse.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Mar 9, 2020

This will be because whatever you have used to configure the colors for
zsh is incorrectly expecting the bold formatting code to make black into
gray. Some terminals still do that because they dont support bold fonts
or for legacy compatibility. Fix whatever it is you are using to set
colors and you will be fine.

Details at: hishamhm/htop#35 (comment)

@PicoJr
Copy link

PicoJr commented Apr 3, 2020

@ritiek did you manage to sort it out?

For now I use the following trick:

theme.conf

# background color also applies to the zsh completion selection
# since my background is dark, I use a bright color for background (bright orange)
background            #ff9c00
foreground            #e0e0e0

background_image ~/Pictures/dark_background.png
# background_tint 0.5
# background_tint must be set to 0 otherwise it tints the terminal with bright orange

result:

kitty_zsh_completion

It looks good enough IMO but I miss the selection rectangle I have when no background picture is used:

kitty_zsh_completion_2

@ritiek
Copy link
Author

ritiek commented Apr 3, 2020

Nope. Seems like zsh doesn't offer a config option for setting this selection color. I also tried to dig in zsh's high-level sources but couldn't find anything interesting there either. This color setting is probably somewhere deep in zsh's core sources.

@kovidgoyal
Copy link
Owner

Its definitely not anything in zsh's core sources. I use zsh with kitty myself, and this problem does not exist. Start with any empty zshrc and bisect it to find the problem.

@ritiek
Copy link
Author

ritiek commented Apr 3, 2020

I should've posted a more informative comment, sorry about that!

If I completely empty my ~/.zshrc, I get no unique highlightning color when a file is selected via tab selections.

I face the original issue when ohmyzsh is enabled and I traced it to this line at fault:

zstyle ':completion:*:*:*:*:*' menu select

(actual source)

from ~/.oh-my-zsh/lib/completion.zsh.

Now if I completely empty my ~/.zshrc again (which also means no ohmyzsh plugins) but this time only put the above single culprit line in ~/.zshrc, I still end up black foreground color with selected file when using tab selections. I guess this has something to do with core zsh but then I don't really know how to debug this single line any further.

@kovidgoyal
Copy link
Owner

You need to figure out where zsh is getting its colors from, most likely
dircolors or something similar.

@trygveaa
Copy link
Contributor

trygveaa commented Apr 3, 2020

I dumped what zsh is sending (by setting the scrollback_pager to tee), and what it sends is \e[m\e[7msome_text. So it's reversing the foreground and background colors.

As far as I understand, the issue is that when background_image is set, kitty doesn't draw background color 0. So when the video is reversed, the background is still not drawn, so you end up with black text on whatever background your background image has.

@kovidgoyal
Copy link
Owner

So then a reproducer would be:

kitty -o background_image=some-image.png sh -c "printf '\e[m\e[7msome_text'; read"

@kovidgoyal kovidgoyal reopened this Apr 3, 2020
@ritiek
Copy link
Author

ritiek commented Apr 3, 2020

Thank you! 5d65cdb does solve this issue for me and I get the same behaviour as gnome-terminal in original post.

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

4 participants