share
Unix & LinuxOn MacOS, what character does `Esc+` or `+Esc` correspond to in Bash, when using iTerm2 terminal?
[+5] [1] Shuzheng
[2020-04-16 09:28:54]
[ bash shell gnu readline macos ]
[ https://unix.stackexchange.com/questions/580428/on-macos-what-character-does-esc-or-esc-correspond-to-in-bash-when-using ]

I've read that mapping Left Option key to Esc+ should fix many of the issues users of Bash, on MacOS, have with GNU Readline key-bindings.

However, I've never encountered Esc+ or +Esc before, so does it mean Esc, Meta, Ctrl, or something else? How can I test what key my Left Option is mapped to after enabled Esc+ or +Esc?

"

[0] [2026-09-16 05:49:31] Stéphane Chazelas

Most likely that means pressing (and releasing) LeftCmd+x would send the ESC control character followed by x.

That's what most terminal emulators do these days and most applications understand reading ESC and x in short succession as meaning the user pressed Meta-x.

In the case of readline, the line editor used by the bash shell, there are a number of options controlling that, which you can set in ~/.inputrc to affect the behaviour of readline globally (in any application that uses it including bash, gdb, GNU bc...) or in ~/.bashrc via it's bind builtin. The behaviour is also affected by the locale. See my answer to another question here [1] for details on that.

So that ESC+ is likely what you need so that for instance at the bash prompt and assuming readline is in emacs mode (set -o emacs in bash which should be the default), LeftCmd+b moves the cursor back by one word like in emacs.

[1] /a/368871

1