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

2

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.

Pageantry answered 6/2, 2020 at 3:59 Comment(0)
L
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}")
Lavernalaverne answered 6/2, 2020 at 10:1 Comment(1)
Perfect, works like a charm. Thank you very much for saving my time and finger muscle pain :)Pageantry
M
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.

Murtha answered 13/10, 2021 at 20:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.