Reputation: 19368
Ctrl + l
is the default shortcut for clear lines in iTerm2, I want to change it to Cmd + l
, but can't find this action:
BTW I'm using zsh.
Upvotes: 4
Views: 3198
Reputation: 18399
This is an zsh binding is not an iTerm binding. Ctrl+l is the default binding for the clear-screen
widget in zsh. The fact that it also works in bash (and maybe other shells) is merely convention. In bash - or rather readline, bash's command line editor - it is the default binding for a command that is also named clear-screen
.
Generally, you can change a key binding in zsh with the command bindkey KEYSEQUENCE WIDGET
. Unfortunately not all modifiers might be supported by iTerm2 for use with the shell. You can test, whether it is supported by running cat -v
and then pressing the desired key combination. If Cmd+l is supported, than the output shown should be more than just "l
". If it something more or other than just "l
", then you can use the output to bind it. For example if cat -v
shows "^[l
" than you can bind it with bindkey '^[l' clear-screen
and if you want to remove the default binding, you can do so with bindkey -r '^l'
.
Upvotes: 2
Reputation: 1518
Ctrl-L
or "form feed" is part of the ANSI/VT100 protocol (http://wiki.bash-hackers.org/scripting/terminalcodes), it's not specific to iTerm2.
Your best best is to use Applescript to send Ctrl-L to the terminal when Cmd-L is pressed.
Upvotes: 4