I use urxvt in combination with zsh. However since my fresh install of ubuntu 10.04 I have the following problem. If I type backspace the cursor moves to the right (instead of deleting the characters on the left).

Suppose I typed n characters then pressing backspace n-times moves the cursor n- positions to the left, if I type backspace then one more, the cursor doesn't move anymore.

If I type the left arrow, nothing happens, if I type the right arrow afterwards a some character occurs.

mv .zshrc .zshrc.bak
mv .Xdefaults .Xdefaults.bak

didn't help.

urxvt + bash works fine as well as xterm + zsh.

zsh-version: 4.3.11-4ubuntu2.is.3ubuntu1 rxvt-unicode version: 9.09-3

Any idea how to fix this?


Try adding the following to your .zshrc:

| improve this answer | |
  • This fixed it for me FWIW. – seth Jul 26 '11 at 22:22
  • 5
    Better use TERM=xterm-256color to support 256 color. – xuhdev Apr 17 '16 at 22:15
  • 1
    Aren't you just avoiding the problem, by using xterm instead of urxvt? – villasv Oct 1 '16 at 12:48
  • 1
    Yes, this worked for me as well. I use the Windows Subsystem for Linux (WSL) with Ubuntu and ZSH and it's been annoying me for so long. Thank you for this. – Dave Reid May 9 '19 at 15:01

In zsh, what does bindkey | grep delete say? These are the lines I get:

"^D" delete-char-or-list
"^H" backward-delete-char
"^[3;5~" delete-char
"^[[3~" delete-char
"^?" backward-delete-char

You should have "^?" as that represents backspace. If not... you can call bindkey "^?" backward-delete-char at the zsh prompt to put it in.

Does that resolve the problem?

| improve this answer | |
  • 1
    bindkey | grep delete "^D" delete-char-or-list "^?" backward-delete-char – student Jul 23 '11 at 18:46

You could also get around the problem by setting

stty erase '^?'

Here are some details about the deviant behavior of certain terminal emulators (which is by the way why certain emulators have this problem): Linux Backspace/Delete mini-HOWTO.

| improve this answer | |

It's an old thread and perhaps no-one will see this, but the issue for me was in the .Xresources file. I had misinterpreted the URxvt*termName parameter as the string that would become the urxvt window title. It is in fact what becomes the $TERM environment variable, unless the shell overrides it (bash does).

My solution was to add URxvt*termName: xterm-256color to the ~/.Xresources file. As with any change to this file, you will need to run xrdb -merge ~/.Xresources and completely restart urxvt (including urxvtd daemon processes) for the changes to show.

| improve this answer | |

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.