2 ms·
Another obscure readline feature is that ~/.inputrc accepts key sequences bound to arbitrary (quoted) macros, including macros that contain more key sequences.
by pdkl95 9y ago
Another obscure readline feature is that ~/.inputrc accepts key sequences bound to arbitrary (quoted) macros, including macros that contain more key sequences.
# a basic macro that types "foo" bound to META+"f"
"\ef": "foo"
The cool part is that bash recursively checks the macro output for more key sequences. For example, I use these standard bindings:
# <META>-k
"\ek": shell-kill-word
# <CONTROL>-y
"\C-y": yank
# <SHIFT>-RIGHT
"\e[c": shell-forward-word
# <SHIFT>-LEFT
"\e[d": shell-backward-word
...which are used by these macros that use s-LEFT and s-RIGHT to move the current command-line argument one position left or right:
# <SUPER>-LEFT
"\e[D": "\e[d\ek\e[d^Y"
# <SUPER>-RIGHT
"\e[C": "\e[d\ek\e[c^Y"
# ^ ^ ^ ^
# | | | > yank
# | | > shell-forward-word
# | > shell-kill-word
# > shell-backward-word
(the actual key sequences depend on the terminal. Check with C-v <KEY>)