70

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.

Vipin Yadav
  • 1,616
  • 1
  • 14
  • 23
  • Shell usage and configuration questions, as opposed to software development questions, are better asked at our sister site [unix.se]. (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). – Charles Duffy May 05 '23 at 21:45

4 Answers4

137

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.

SergioAraujo
  • 11,069
  • 3
  • 50
  • 40
  • 16
    Thanks a lot. That did the work. I used `fg=23`, which I found best for `Solarized` dark theme. – Vipin Yadav Nov 16 '17 at 04:28
  • 16
    How about `fg=10`, it's a dark grey, a bit darker than the regular Solarized font, but still visible the difference. – Krzysztof Wolny Sep 14 '18 at 21:15
  • 7
    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'` – Ale Felix Sep 23 '20 at 01:55
  • List of the 256 colors can be found [here](https://www.ditig.com/256-colors-cheat-sheet). e.g. if you want to use the color 10, use `fg=10` – Anwarvic Aug 31 '22 at 20:37
32

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

MatrixManAtYrService
  • 8,023
  • 1
  • 50
  • 61
  • 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. – david_nash Jun 20 '19 at 06:37
  • saved my day, thanks! – dasdachs Nov 02 '21 at 15:43
  • tried many numbers as per https://robotmoon.com/256-colors/, my fav fg value is 16 on solarized dark esp running inside tmux, 10 is the second. – yjqg6666 Jun 22 '22 at 03:36
22

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.

BenYR
  • 321
  • 2
  • 3
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
jasonleonhard
  • 12,047
  • 89
  • 66