Duplicated characters and non-updating input using tmux in zsh

4.4k Views Asked by At

First off: I'm using tmux 2.5 installed via homebrew on OS X 10.12, in iTerm 2 (though the problem appears in Terminal.app as well). My tmux.conf is on Github, along with my zshrc.

The problem: Seemingly out of nowhere, I started seeing an issue with typing in the prompt. Typing keys once will display them twice, and backspacing will move the cursor forward and redraw characters already present on the line. This only happens inside of a tmux session, and not inside my "regular" terminal.

Here's a gif of the issue. In this gif, I type 1234567890, then hit backspace 9 times, and type ls. Note that 0 only shows up once, and lls with a duplicated l runs the ls command as expected.

gif of weird input behavior

Hopefully I just hit a weird key combo on accident, but I've been stuck on this for a while.

Thanks for any help!

3

There are 3 best solutions below

1
On

The problem seems to be fixed after commenting out this line from my tmux.conf:

set -g default-command "reattach-to-user-namespace -l zsh"

I also had to manually run tmux kill-server instead of relying on just re-sourcing my conf file.

When I find some time, I'll look more into what went wrong here...

0
On

I'm also running into this issue as well. I encountered the problem similar to @artemave, by trying to change the set -g default-terminal "screen-256color" to set -g default-terminal "tmux-256color". The goal of doing this was to gain italics, per the tmux FAQ.

@taylor's answer didn't work for me, as I didn't have that command.

I managed to determine that:

  1. The issue doesn't occur with bash

  2. When running a blank .zshrc, backspacing creates new blank lines, but I'm not seeing the character duplication

  3. Using tmux-256color will successfully give italic fonts

  4. Using TERM=xterm-256color and TERM=konsole-256color does not change the above effects

  5. Using xfce4terminal (0.8.9.1), Konsole (19.12.3), or URXVT (9.22) doesn't change the above behavior

I wasn't able to really "fix" the issue, as the even going down to a blank .tmux.conf wasn't able to change anything. Instead, I just needed to change it to anything else. xterm-256color was suggested in this issue, but I found nearly anything else would work fine.

I'll keep working on it and update this answer if I find anything else.

Edit: This tmux issue is the exact issue we're running into. I'll see if the solutions there work

https://github.com/tmux/tmux/issues/597

Edit 2: I've submitted a GitHub issue with tmux. No real results yet, but it does offer some guidance on things to check on.

1
On

Installing tmux-256color for macOS as in this guide solves the problem.

Running the following as mentioned in a github issue solved the problem for me:

brew install ncurses
$(brew --prefix)/opt/ncurses/bin/infocmp tmux-256color > ~/tmux-256color.info
tic -xe tmux-256color tmux-256color.info
infocmp tmux-256color | head