'Backspace in zsh fails to work in quite the strange way

I'm on a fresh Virtualbox install of CentOS 6.4.

After installing zsh 5.0.2 from source using ./configure --prefix=/usr && make && make install and setting it as the shell with chsh -s /usr/bin/zsh, everything is good.

Then some time after, after installing python it seems, it starts acting strange.

  1. Happens with PuTTY and iTerm2 over SSH, does not happen on the raw terminal through Virtualbox.
  2. typing something, then erasing it: rather than removing the char and moving the cursor back, the cursor moves forward.
  3. Typing Ctrl+V then Backspace repeatedly prints out this repeating pattern '^@?'
  4. Running cat from zsh works fine. Prints out '^H' if I type that, backspaces like normal if I type normal backspace.

Surely someone's seen this before and knows exactly what the hell it is.

I'm not positive yet, but it seems that installing oh-my-zsh can fix this. But I really want to know what the specific issue is here.



Solution 1:[1]

sigh I knew I solved this before.

It's too damn easy to forget things.

The solution is to compile and apply the proper terminfo data with tic, as I have a custom config with my terminal clients, xterm-256color-italic, that confuses zsh.

There appear to be other ways to configure this stuff too; I basically just need it to be properly set up so italics work everywhere (including in tmux) so hopefully I can figure out how to do this more portably than I am currently.

Solution 2:[2]

OK , I suggest you try

export TERM=xterm

in your .zshrc configuration

the Changing into Zsh caused the bug.

Solution 3:[3]

I encounter the same problem when I manually install ZSH without root, when the backspace turns to blankspace but still functions as Backspace. Finally, I find it is because "ncurses" is not installed well.

tic: error while loading shared libraries: libncurses.so.6: cannot open shared object file: No such file or directory ? tic could not build /home/user/ceph-data/soft/ncurses-6.1/share/terminfo

After I reinstall the "ncurses", the problem of ZSH backspace is solved. Just for your information.

my $TERM is xterm-256color, by the way.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Steven Lu
Solution 2 ctix
Solution 3 Yanwen Wei