2

I have following custom zsh keybindings for the alt (meta) + left and right arrow key withi os x Iterm2 and +Esc setting for meta

bindkey "^[^[[D" backward-word
bindkey "^[^[[C" forward-word

This allows to jump by word on the shell like in most gui text editors with alt arrow.

However when starting tmux session those bindings just print following on the screen.

DCDCDC 

Any idea how to make zsh within tmux accept the bindings.

1

Escape indicates meta only for combinations of the form Meta+c where c is a printable character or a control character. Most terminals do not prepend an escape character to escape sequences, so that you can type two consecutive escape characters to trigger the Escape binding in applications, and so that escape sequences do not contain control characters after the initial escape character.

To see what escape sequence your terminal sends for a keystroke, press Ctrl+V then that keystroke, e.g. Ctrl+V then Meta+Left, at a shell prompt or in cat. In a terminal in cooked mode and in applications such as shells and Vi, Ctrl+V means “insert the next character literally even if it is a control character”, thus Ctrl+V followed by a keystroke that sends an escape sequence results in inserting that escape sequence (assuming that the escape sequence doesn't contain any control character apart from the leading escape character).

You'll probably see something like this:

^[O1D

meaning that Meta+Left sends the escape character followed by the three characters O1D. This means that you need the binding

bindkey "^[O1D" backward-word
  • the escape sequence i posted are printed like this in tmux and Iterm2 within cat. also other bindings work exactly the same in both. Just alt arrow is not working in tmux – dre-hh Jul 9 '18 at 7:24
0

Add set-option -g xterm-keys on to tmux.conf or enter :set-option -g xterm-keys on inside tmux everytime.

  • unfortunately that did no help – dre-hh Jul 6 '18 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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