0

ZSH normally works fine except when I use it in Tmux. When I press ALT or CTRL before any other keys like Alt + Left Arrow (to jump by words) or Alt + Backspace (to delete a word), it suddenly changes the prompt from this style:

enter image description here

to this style:

enter image description here

Then nothing works until I press the same key but with the Right Arrow key like Alt + Right Arrow.

It works fine when I do the same without Tmux, but I have no clue why it doesn't work in Tmux.

1 Answer 1

1

tmux probably send other sequences for these key combinations to the shell as does your other terminal.

Check what you get after pressing CTRL+V (entering into a verbatim mode) and then the key combination in the different terminal emulators. With xterm I get e.g. ^[[1;3D] for ALT+LEFT ARROW.

Then find where you define your keybindings (probably ~/.zshrc) and change or better augment these for these new sequences.

Assuming you had before

bindkey "^[b" backward-word

just make it two lines, the second for the newly identified sequence:

bindkey "^[b"      backward-word
bindkey "^[[1;3D]" backward-word
3
  • Thank you. When I press Ctrl-v and any other keys, it shows me a code, but not for the Alt-Backspace key :'(. After pressing Ctrl-v Alt-Backspace, it change the arrow from > to < and nothing prints.
    – mortymacs
    May 12, 2021 at 16:31
  • 1
    @mortymacs: I see, I did got a code on xterm and assumed it is working. Maybe you could first try to use bindkey '\M-^H' ... but this is probably the default. I'm no tmux expert, but I found unix.stackexchange.com/q/57827 maybe this will give you some clue.
    – mpy
    May 12, 2021 at 17:21
  • 1
    Thank a lot! bindkey -e ${$(tput kDC3 2>/dev/null):-'\e[3;3~'} kill-word fixed the issue which they mentioned in the answer.
    – mortymacs
    May 12, 2021 at 17:56

You must log in to answer this question.

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