Why do `ctrl+[` and `ESC` both produce `^[`?
10
votes
3
answers
2784
views
In bash, I press ctrl+v to start verbatim insert. In the verbatim mode, I press the Esc key and bash shows
^
. I redirect it to file esc
.
Also in the verbatim mode, I press ctrl key with [ key, and bash shows ^[
. I redirect it to file ctrl
.
Next, I compare the two files, and they are the same!
$ echo '^[' > esc
$ echo '^[' > ctrl
$ diff esc ctrl
$
Why do Ctrl+[ and Esc produce the same content?
Is ^[
here [the C0 and C1 control codes ? If so, the wiki article says ^[
is Escape, so why is ctrl+[ also Escape?
The root problem is that I want to check and create a key binding.
(zsh)$ bindkey -L
...
bindkey "^['" quote-line
...
So do I need to type ESC+'
or ctrl+[+'
?
Asked by Gqqnbig
(249 rep)
Oct 16, 2022, 11:42 AM
Last activity: Nov 14, 2024, 12:12 PM
Last activity: Nov 14, 2024, 12:12 PM