Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to bind <C-h> to execute tmux slect-window -t -1, <C-l> to execute tmux slect-window -t +1 in zsh, can I do it?

share|improve this question

1 Answer 1

You could solve this by adding a couple of zsh functions, registering them as zle widgets, and then use bindkey to map them to hotkeys.

I wouldn't want to bind anything to <C-l> though, since that's usually the keybinding for clear, and I use that quite a lot.

This should solve your problem:

control_h() {
  tmux select-window -t -1
}
zle -N control_h
bindkey "\Ch" control_h

control_l() {
  tmux select-window -t +1
}
zle -N control_l
bindkey "\Cl" control_l

How to create basic keyboard shortcuts in zsh is covered here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.