I have a settings and a zsh session
~ bindkey | grep help "^[H" run-help "^[h" run-help
Why when i press "Control + [ + h" word under cursor removes and nothing happens, but if i press "Alt + h" man page opens correctly?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
Try pressing Control+[ immediately followed by h.
Terminals do not send key presses directly to the shell (as in Control was pressed/released). Instead the terminal sends character sequences depending on keys pressed. The keys in a sequence are to be pressed - well - in sequence, not all at once. The big exception to this are the Control-keys and the Alt-keys which are pressed at the same time with other keys to create a specific sequence.
As you already know/noticed
^ is used as symbol for the Control-key, but it only has this meaning in conjunction with the following character.
^A means Control+a or Control+A, the key sequence is the same for upper and lower case characters in combination with Control (that is also the reason why terminals often use Control+Shift+SOMEKEY for their own, not shell-related shortcuts).
^[ literally means Control+[. It is also sent by the Escape. So
^[a means Control+[ followed by a (lower case!). Additionally, the Alt-key also sends the
^[ sequence followed by the key it was pressed with. So Alt+a also sends
^[a. Alt+Shift+a sends
So for your example you can press either of these ('+' means "at the same time", ',' means "in sequence"):
Special keys like PgUp, Backspace, Return or KP_Enter also send key sequences. These often depend on the terminal emulator. You can use the
vi-quoted-insert widgets to show the key sequence. By default they is bound to
^V in their respective modes. So pressing Control+v followed by the key combination in question will show the sequence you can use for
termite on my machine I get:
^[[5~, which is also Control+[,[,5,~ or Escape,[,5,~ or Alt+[,5,~
^?, which is also Control+?
^M, which is also Control+m
^[OM, which is also Control+[,Shift+o,Shift+m or Alt+Shift+o,Shift+m
In theory the key sequences can be arbitrarily long and complicated. For example with:
bindkey '^[xfooba^r' run-help
Alt+x,f,o,o,b,a,Control+r will run the
There is a bit of a limit as
zsh only waits a certain time for another character, before it accepts a multi-character sequence. This timeout can be configured in the
KEYTIMEOUT parameter in hundredths of seconds. The default is
40, so 0.4 seconds.