Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .