How to change zsh-autosuggestions color

26,040

Solution 1

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

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

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.

Share:
26,040
Vipin Yadav
Author by

Vipin Yadav

Exploring JavaScript ecosystem.

Updated on December 17, 2020

Comments

  • Vipin Yadav
    Vipin Yadav over 3 years

    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.