In zsh, how do I bind a keyboard shortcut to a function?
In other words, how do I translate:
bash:
hw(){ echo "hello world"; }
bind -x '"\C-h": hw;'
to zsh?
keyboard shortcutszsh
In zsh, how do I bind a keyboard shortcut to a function?
In other words, how do I translate:
bash:
hw(){ echo "hello world"; }
bind -x '"\C-h": hw;'
to zsh?
Best Answer
It won't take the functions raw. They need to be wrapped in a "widget" by doing
The two can have the same name:
Then it's possible to do:
, causing
Ctrl+h
to run thehw
widget which runs thehw
function.