zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.43k stars 1.85k forks source link

Command-specific suggestion strategies #690

Open akim-13 opened 2 years ago

akim-13 commented 2 years ago

Is your feature request related to a problem? Please describe.

It doesn't make sense to use the same suggestion strategy for e.g. man and cd. If you type cd <TAB> in home it might suggest some sub directory which you cannot currently cd into. Same for man <TAB>, it will suggest some rubbish instead of the last searched man page.

Describe the solution you'd like

Allow to define command-specific ZSH_AUTOSUGGEST_STRATEGY arrays. This way it would be possible to have ZSH_AUTOSUGGEST_STRATEGY=(completionhistory) for cd, and ZSH_AUTOSUGGEST_STRATEGY=(historycompletion) for man.

Describe alternatives you've considered

Maybe it's already an existing functionality, I just couldn't find it.

ericfreese commented 1 year ago

The plugin doesn't support the feature exactly as you've described it, but would setting ZSH_AUTOSUGGEST_HISTORY_IGNORE possibly work for you? It would allow you to suppress history suggestions for certain prefixes like cd.

See the section of the readme here: https://github.com/zsh-users/zsh-autosuggestions#ignoring-history-suggestions-that-match-a-pattern