How to change zsh-autosuggestions color
Asked Answered
C

4

71

I am new at zsh.

I've installed the plugin zsh-autosuggestions in oh-my-zsh using instruction mentioned here. I am using Linux (Fedora 26).

What my problem is I want to change the color of the text which comes in suggestion because the current one is not visible in Solarized dark color scheme.

enter image description here

It is visible in light theme

enter image description here

And it works fine as I can pick the current suggestion by pressing key.

My question is that how can I change this suggested text color? I read here that there is a constant ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE, but I am unable to locate that nither in ~/.zshrc file nor in $ZSH_CUSTOM/plugins/zsh-autosuggestions directory.

Can anyone tell me where can I find that and how can I change that? Also please suggest the color which will be suitable for both dark and light theme.

Also please correct if I am going wrong.

Regards.

Crowl answered 15/11, 2017 at 14:54 Comment(1)
Shell usage and configuration questions, as opposed to software development questions, are better asked at our sister site Unix & Linux. (The general rule is "could anyone who's not developing software have this problem?", and system administrators and other users can certainly want to change their shell's color scheme).Links
A
142

You can edit your ~/.zshrc and change/add the variable: ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=value'

I have just tested the value from fg=8 to fg=5. I think fg stands for Foreground.

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=5'

**OBS: Add the above line at the end of your zshrc (after loading the plugin) **

I have found another reference here.

Amenra answered 15/11, 2017 at 17:12 Comment(4)
Thanks a lot. That did the work. I used fg=23, which I found best for Solarized dark theme.Crowl
How about fg=10, it's a dark grey, a bit darker than the regular Solarized font, but still visible the difference.Jillianjillie
It looks like you can also use the hex color codes, for some reason my terminal was showing white suggestions with all the grey color options, but it works perfectly with ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#757575'Mchenry
List of the 256 colors can be found here. e.g. if you want to use the color 10, use fg=10Urinal
V
35

Here is a list of the color numbers: https://coderwall.com/p/pb1uzq/z-shell-colors

I settled on this one for solarized dark:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=60'

...and this one for solarized light:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=180'

I keep these in separate files (which do other color-theme manipulations) so that whenever somebody turns the lights on or off, I can just source the appropriate file, restart my terminal, and carry on.

My solution requires a little manual editing to make work, but you might find it interesting: https://github.com/MatrixManAtYrService/colorshift

Villada answered 30/10, 2018 at 18:37 Comment(3)
This was the best solution for me, though I'd suggest pasting the clicolors() function from the first link. Running that function really helped me see what what my colorscheme was doing.Avellaneda
saved my day, thanks!Consignment
tried many numbers as per robotmoon.com/256-colors, my fav fg value is 16 on solarized dark esp running inside tmux, 10 is the second.Annabel
O
23

To add to SergioAraujo's useful answer, the ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=<value>' setting follows the xterm-256-color convention. So you can actually choose a value for fg from a standard xterm 256 color chart (such as the one found here) rather then playing the guessing game.

Ontiveros answered 9/10, 2018 at 5:26 Comment(0)
C
0

After experimenting, here are a few I liked that you might also:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=cyan,bg=#ff00ff,bold" 
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=white,bold,bg=#ff00ff,bold"
man zshzle # more info here if you want
Colonnade answered 5/5, 2023 at 20:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.