I want to disable Insert key completly in zsh. This key has no real use, and only annoys me when I hit it accidentally.
I found how to remove the binding for overwrite-mode
bindkey -r "^[[2~"
But now, when I actually hit Insert, instead of activationg overwrite-mode, it prints ~
on the cursor position.
Similar thing happens when I press F12, which is not bound to anything. It also prints ~
.
How can I disable the Insert key completely (and F12, as well), so that pressing it does not do anything in zsh?
I don't want to disable Insert key globally, because some other programs may actually use it for useful purpose.
Best Answer
If you press a special key (such as Insert) which sends an escape sequence that is not recognized by
zsh
, it will do this. zsh will try to do something with the individual bytes of the escape sequence.Looking at the result from
bindkey
, it seems that zsh has no suitable function which can be bound to a key to ignore it. But you could rebind Insert to an empty macro:Likewise for F12. Press Ctrl+V F12 to see what escape sequence F12 sends, typically
According to the
zshzle
manual page, there is a limitation with this approach:Binding to
\a
as I originally suggested does not appear to have this drawback, i.e.,