I'm trying to setup an alias in OS X that will be run by a keyboard shortcut or hotkey. Is this possible?
alias newtab = "command+t"
I'm trying to setup an alias in OS X that will be run by a keyboard shortcut or hotkey. Is this possible?
alias newtab = "command+t"
to determine which command is run by a Zsh keybinding, you should use describe-key-briefly
. Which IIRC in emacs mode is assigned to ^hk
(control-H
and then k
). So you would type ^Hk
and after that whichever keybinding you wish to inspect. Example ^hk ^r
To see all your bindings, just call bindkey
without any arguments.
[...]
Now to answer your original question. To bind a Zsh function to a (shell) key binding, you should define a function that does whatever you want (not an alias...)
function hello() { echo "hello... I am running..." }
zle -N hello
bindkey "^hh" hello
now when you type ^hh
you will run that function. See the manual for zle
and bindkey
.