You can't use \M-
because it's broken. Keep using \e
for the Meta/Alt prefix.
Using \M-
in readline bindings does not work reliably with terminal emulators which prepend an ESC (\x1b
) character instead of turning on the high bit when Meta/Alt is pressed and/or with UTF-8 locales (both of which are generally the default on most modern systems [1]).
With some versions of bash (e.g. 5.0
, but not the newer 5.1
), using \C-\M-
works differently from \M-\C-
, so just using \C-\M-k
instead of \M-\C-k
may actually do what you want -- until the next update ;-)
bash-5.0$ bind '"\C-\M-k": shell-backward-kill-word'
bash-5.0$ bind '"\M-\C-k": shell-kill-word'
bash-5.0$ bind -p | grep -a shell-.*kill-word
"\e\C-k": shell-backward-kill-word
"\213": shell-kill-word
[1]: not with xterm
though, where you would need something like XTerm*VT100.metaSendsEscape: true
in your ~/.Xresources
.