Score:0

Changing zsh-autosuggestions color

kr flag

I have installed zsh-autosuggestions plugin in oh-my-zsh.
I'd like to change the colour of the text which comes in suggestion. My current color is very similar to that of what comes before.

Please see the image below.

enter image description here

This setting is probably govern by ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE setting. But when I add e.g. ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=60' the following happens:

enter image description here

What I'd like to have is bin in much different color than cd.

sancho.s ReinstateMonicaCellio avatar
pl flag
The behaviour you observed seems different from what is described [here](https://stackoverflow.com/questions/47310537/how-to-change-zsh-autosuggestions-color), e.g., which looks the same as you expected to get. Is this correct?
kr flag
@sancho.sReinstateMonicaCellio It is similiar. If it is the best option I can get, it will do.
WU-TANG avatar
cn flag
@menteith so are you saying that 60 is the only color that you are willing to use, but you want it to show up different? Basically all the answers below say there are 254 other colors, plenty of which will display different..... Or, on your system, does all 255 colors show up the way it shows in your picture? I would find that hard to believe because fg=60 shows up the same way on my screen as it does on yours, but the other colors, on mine, show as advertised.... see the chart in my answer and reference "60"... Let me know if I am misunderstanding?
Score:0
my flag

Refer to the official documentation available on GitHub:

Set ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE to configure the style that the suggestion is shown with. The default is fg=8, which will set the foreground color to color 8 from the 256-color palette. If your terminal only supports 8 colors, you will need to use a number between 0 and 7.

Background color can also be set, and the suggestion can be styled bold, underlined, or standout. For example, this would show suggestions with bold, underlined, pink text on a cyan background:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"

For more info, read the Character Highlighting section of the zsh manual: man zshzle or online.

Note: Some iTerm2 users have reported not being able to see the suggestions. If this affects you, the problem is likely caused by incorrect color settings. In order to correct this, go into iTerm2's setting, navigate to profile > colors and make sure that the colors for Basic Colors > Background and ANSI Colors > Bright Black are different.

So, you can change the colour of the suggestions and make them bold (maybe even underlined).

Modify the ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE to:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#d787ff,bold'

It'll make it appear much brighter than before.

You might want to change it to some other colour, for example, Cyan:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#00ffff,bold'

You might like underlining the suggestion:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#00ffff,bold,underline'

For the colour chat refer to the colour palette.

sancho.s ReinstateMonicaCellio avatar
pl flag
Do you think this answer adds to what the OP tried (other than explaining in more detail that same configuration)? Why would this produce a result essentially different from what the OP reported, in the sense of solving his/her problem?
Score:-1
in flag

First I'd start with a setup the author uses:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"

Test this elaborate highlighting first and if it works, then dial it down to your preferences.


Also there is a setup issue reported on GitHub that might be effecting you:

Please read the entire thread but the most important part is below:

It turns out the zsh-syntax-highlighting plugin is conflicting somehow. I commented it out and everything worked as expected.

exec zsh, instead of sourcing .zshrc also works so I'll use that

Score:-1
ng flag

You can use:

# Change <your color> to a valid color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=<your color>"
# For example, to make the text red:
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff0000"

The result will be like below, depending on the config you actually used: ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff0000"

You can append that line of setting to .zshrc.

EDIT: It is also possible to do almost any formatting on the suggested text. Here are some examples. ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff0000,bg=#00ff00,underline" ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff0000,bg=#00ff00,underline,standout,bold"

For a full list of formatting syntax, see it's official documentation. Hope you enjoy the reformatted texts and have a good day!

Score:-1
cn flag

I always use this color for contrast in terminals: (in my .zshrc file, I'd add)

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#00FF00,bold"

You're getting the color that you selected... 60 is a light magenta-ish color. I cut and pasted the script from here into my terminal and it output the color chart on that page to my terminal... displaying your "60" selection...

If I wanted to use those kind of codes to set my color preference, I'd do something like:

ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=46,bold"

...and get a similar result to the hex/rgb code in my 1st example above.

(in other words, there's nothing wrong, you're just picking a color you don't want.... pick another color, the chart(s) in the link above should help)

echotc Co will tell you how many colors your terminal supports, but I doubt you're going to need to verify that because you are getting the correct color for "60", so it is most likely 256.

Edit: I didn't realize there were so many charts and scripts on that page in the link. I just used the accepted answer from Tom Hale...

enter image description here

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.