zsh-users / zsh-autosuggestions

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

Is there a way for a bindkey to run two commands? #624

Closed amorfinv closed 3 years ago

amorfinv commented 3 years ago

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

I'd like a bindkey that combines autosuggest-disable and then autosuggest-enable. Basically, I want to disable autosuggest, execute my command, and then enable autosuggest without having to use two bindkeys. autosuggest-disableandautosuggest-enable` (or autosuggest-toggle two times).

Describe the solution you'd like

1) I start typing out a command. image 2) I execute a bindkey to disable autosuggest image 3) I finish typing my command without autosuggest and then execute image 4) After executing autosuggest should be automatically enabled without having a new bindkey.

My laziness is kicking in so the extra microsecond of work would be nice to avoid.

Describe alternatives you've considered

I have tried to read a bit through some issues/documentation but I did not find out if there is a way to do this. However, there are somethings I don't understand so there is a high chance that I missed an explanation.

Thanks, -Andres

ericfreese commented 3 years ago

Hi, I think I would try using something like add-zle-hook-widget line-init autosuggest-enable (add to your .zshrc after sourcing zsh-autosuggestions) to always try to re-enable the suggestions when starting a new prompt.

See the docs for add-zle-hook-widget here https://zsh.sourceforge.io/Doc/Release/User-Contributions.html#ZLE-Functions

amorfinv commented 3 years ago

Worked perfectly @ericfreese. Thank you!