In GNU readline manual, it says the left Alt is usually Meta:
The Meta key is labeled ALT on many keyboards. On keyboards with two keys labeled ALT (usually to either side of the space bar), the ALT on the left side is generally set to work as a Meta key.
But by experiment, I think the left Alt is actually ESC, rather than Meta. That's because, given the following inputrc configuration:
"\eB": vi-bWord
Pressing AltShiftb works as expected.
However if I change the key binding to the following:
"\M-B": vi-bWord
Pressing AltShiftb does nothing.
I'm wondering why Alt is actually ESC instead of Meta? How to change Alt to act as Meta key?
INPUTRC=/dev/null LC_CTYPE=C bash --norc
. I don't think that\M-
works with utf-8 locales (haven't tried too much either, though ;-))."\eB"
and"\M-B"
should be synonymous.LC_CTYPE=C
trick. This is interesting -- in UTF-8 locales,bind -p
shows all\e
ESC prefixed key bindings, while in C locale they are just\M-
prefixed as advertised in the manual. Seems Meta has some other uses in non-C locales? Combining several clues presented to me, including the answer linked by @muru (which I do not understand 100%) and readline variables likeinput-meta
,output-meta
,convert-meta
, I vaguely think Meta is not normally used because somehow\M-
prefixed keys conflict with multi-byte characters??cat
and pressing ALT-p: it should print^[p
). The problem is why"\eB"
and"\M-B"
are only considered synonymous in bindings whenLC_CTYPE
is C -- I haven't got an answer for that, yet.