How to change zsh-autosuggestions color

LinuxZshOh My-ZshZshrcZsh Completion

Linux Problem Overview


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.

Linux Solutions


Solution 1 - Linux

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 found another reference here.

Solution 2 - Linux

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

Solution 3 - Linux

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVipin YadavView Question on Stackoverflow
Solution 1 - LinuxSergioAraujoView Answer on Stackoverflow
Solution 2 - LinuxMatrixManAtYrServiceView Answer on Stackoverflow
Solution 3 - LinuxBenYRView Answer on Stackoverflow