Search code examples
zshoh-my-zshzsh-completion

Changing the acceptance key (autosuggest-accept) - ZSH shell on mac


on > zsh mac terminal
if i type c and get the autocompletion suggestion as clear

To accept that suggestion i need to hit right arrow key and then press enter to run it. I want to change the right arrow key to something else for example ` OR '

Plese help on finding a way to change this behaviour.


Solution

  • You can change bindkey for autosuggest-accept widget.

    bindkey '`' autosuggest-accept
    

    Note that this will disable your ability to type ` character directly though. If you want to execute the autosuggest immediately after hitting `, change autosuggest-accept to autosuggest-execute.

    To make this change permanent, add the bindkey line to your ~/.zshrc

    If you also want to disable arrow key, you can remove the widget from ZSH_AUTOSUGGEST_ACCEPT_WIDGETS array.

    ZSH_AUTOSUGGEST_ACCEPT_WIDGETS=("${(@)ZSH_AUTOSUGGEST_ACCEPT_WIDGETS:#forward-char}")