3 ms·
You don't need to implement this in the terminal. You can bind macros to keys in anything that uses readline. Search for "inputrc" and the READLINE section in b
by pdkl95 10y ago
You don't need to implement this in the terminal. You can bind macros to keys in anything that uses readline. Search for "inputrc" and the READLINE section in bash(1). While this is usually used for binding builtin functions (i.e. editing, history), you can simply provide the literal expansion.
# in ~/.inputrc
$if Bash
# <f12> - find this with "<Control-v>{KEY}"
"\e[24~": "sh \"${HOME}\"/path/to/swap_config.sh
"
# (the newline is included, which is
# usually bound to accept-line)
$endif
The string indicating the key to binding to (left of the ":") can change depending on the environment (terminal, os, etc), so use <Control-v> to investigate what is actually being sent by the terminal into readline.
- saghm 10y agoThanks! Unfortunately I use zsh, and from a quick Google, it looks like it doesn't use inputrc.