Control-Backspace (unix-kill-rubout) for readline?

Solution 1:

Adding

"\C-_": unix-word-rubout

to .inputrc seems to work for me.

The C-_ represents control underscore. This is what my terminal sends when pressing Ctrl+Backspace.

Pressing Ctrl+V then a key combination will echo its code to the console. For me, pressing Ctrl+V then Ctrl+Backspace echoes ^_ with ^ meaning Ctrl. In .inputrc \C- is the Ctrl modifier so \C-_ is what's needed here. You can use this technique to determine other key combinations you may want to use.

Solution 2:

As graywh points out backspace is often represented by ^?. In order to bind to ctrl+bksp in your .inputrc file you may need modify your readline library. This ubuntu tutorial includes a new .keytab file which can override the default output.

On my system this let me add "\e[9;3~": backward-kill-word to my .inputrc.

As readline behavior seems to vary somewhat based on your system, it's worth noting I'm using Konsole on Kubuntu.

Solution 3:

  • Assuming you use gnome-terminal, this would require a patch.
  • For konsole, you need a configuration change.
  • For xterm (maybe urxvt has something similar), another configuration change.