Open creednaylor opened 3 years ago
There's not really a supported way to do this right now. I was thinking that you may be able to write custom strategy wrapper functions around the history
and completion
strategy functions and set ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE
accordingly in those wrapper functions, but that only works without async mode enabled, because in async mode the suggestion fetching runs in a separate process so can't set the value of the highlight style variable for the original process.
_zsh_autosuggest_strategy_color_completion() {
_zsh_autosuggest_strategy_completion "$*"
typeset -g ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=red'
}
ZSH_AUTOSUGGEST_STRATEGY=(color_completion)
The way the async code works right now, the only thing communicated back to the main process is the actual suggestion. It doesn't send any info about what strategy generated the suggestion, so we'd need to figure that out first. This is the place where we get data back from the async process:
Maybe the async process could always send the name of the strategy that generated the suggestion as a separate line at the beginning.
We'd also need to modify the _zsh_autosuggest_fetch_suggestion
function. Currently it only "returns" the suggestion (by setting the global suggestion
parameter) but we'd need it to potentially set another global param to send the strategy back as well.
Wow thanks @ericfreese for the detailed reply! Interesting. I'm not too familiar with zsh and shell scripting in general so I don't know if I'd be able to make the changes myself. Do you think this is something that people would want? (I do :) )
Would it be a change that a contributor to the repo would want to make?
I know that:
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
will first try to find a suggestion from thehistory
, but, if it can't find a match, will find a suggestion from thecompletion
engine.ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE
configures the style that a suggestion is shown with.Question: Is there a way to show one font color (e.g. red) for suggestions from my
history
and another font color (e.g. blue) for suggestions from thecompletion
engine?