Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.inputrc override Control+W

How do I override Control+W in bash within my .inputrc? The following on its own doesn't work:

"\C-w": forward-word

It does work when I add stty werase undef but then the 's' key is mysteriously disabled!

like image 760
Raine Revere Avatar asked Oct 19 '25 14:10

Raine Revere


1 Answers

You need to use the option set bind-tty-special-chars Off in your .inputrc file in order to bind ^W like that. The reason is that:

Readline, beginning with version 5.0, reads the stty special character settings and binds them to their readline equivalents each time readline() is called from bug-bash mailing list

The bind-tty-special-chars option was introduced in 5.1 in order to work around this feature. Readline Changes - search for the option

set bind-tty-special-chars Off
"\C-w": forward-word

The slightly older-school method involves .bashrc like:

stty erase undef
bind '"\C-w": forward-word'
like image 78
Petesh Avatar answered Oct 21 '25 04:10

Petesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!