1

My terminal has recently started printing control characters (e.g. ^P or ^N) when I press Ctrl+P (or other combinations). I'm not sure what caused the change. Here is my .tmux.conf file. Any ideas?

Note that ^C, ^D, and a few others still work as expected.

Edit I just realized that it works when using bash inside of tmux, but not with my usual zsh. Any ideas?

Edit 2 I think this was a load order problem. In my .zshrc I set EDITOR=vim, which causes zsh to switch to vim keybindings. However, for a normal terminal session, apparently it was being set too late, but when tmux is run, a new zsh process is started, and this time EDTIOR is already set to vim, so it switches to vim keybindings. Putting bindkey -e right after EDITOR=vim in my .zshrc fixed the problem.

  • Please check, if bindkey -v or more specifically bindkey '^P' up-line-or-history makes CTRL+P working again. – mpy May 7 '14 at 20:25
  • The second command makes it work again, however ^N still doesn't work. Could this be tmux switching readline to vi mode? And if so, how do I switch it back to emacs mode. – Eric Andres May 7 '14 at 20:31
  • zsh isn't using readline, but zle. Have you tried bindkey "^N" down-line-or-history accordingly? Have you updated zsh, installed oh-my-zsh or something similar lastly? – mpy May 7 '14 at 20:42
  • Regarding emacs keybindings, try bindkey -e. – mpy May 7 '14 at 20:53
  • @mpy I think that solved my question. If you put that in an answer, I'll gladly accept it. Thanks for your help. – Eric Andres May 7 '14 at 21:59
2

The keybindings in the Z shell are controlled via the bindkey builtin. To enable the usual emacs or vi keybindings use bindkey -e or bindkey -v, resp.

You mention that you included EDITOR=viminto your zshrc file. This influences the default choice for the key bindings as explained by the zshzle manpage:

If one of the VISUAL or EDITOR environment variables contain the string vi when the shell starts up then [the main keymap] will be viins, otherwise it will be emacs. bindkey's -e and -v options provide a convenient way to override this default choice.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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