In bash one can do the following:
bind -x '"\C-l":ls'
to map Ctrl+L to external (ie. system's rather than readline function)
ls
command to list directory contents.
How to do the same in zsh, and preferably with Alt (\M-l
?)
instead of Ctrl as it is seemingly already bound to clear
to clear the screen.
Best Answer
This binds control+l because I don't know what
\M-l
generates for you; runningread -r
and then mashing keys might show something suitable to use withbindkey
, or runbindkey
with no arguments to show what is already set. For more information on bindkey and widgets, seezshzle(1)
.