5

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.

Chandan Nayak
  • 10,117
  • 5
  • 26
  • 36

2 Answers2

6

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}")
rcwnd_cz
  • 909
  • 6
  • 18
4

As a more out-of-the-box solution, I just found out here that you can use:

CTRL+E

instead of the right arrow, and it will accept the autosuggestion.

In the link they refer to it as "end-of-line in emacs mode", but I didn't configure anything of the sort, so I guess it just works.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Bruno Belotti
  • 2,414
  • 1
  • 31
  • 28