I checked docs for readline (in man bash), and I can't find a way to solve one problem: how to change readline setting (set ... on/off) on keypress?

Keybindings seem to have form:



key:"string to enter"

but when I tried:

key:set .... off

it didn't work.

1 Answer 1


You can use the bind builtin command with -x option.

A variable may be set with bind "set var val"
bind -x keyseq:command cause command to be executed when keyseq is entered
So, bind -x 'keyseq:bind "set var val"' works fine.


bind 'set expand-tilde off'
bind -v | grep expand-tilde
# outputs set expand-tilde off
bind -x '"\C-x\C-t": bind "set expand-tilde on"'

Press Control+x, Control+t

bind -v | grep expand-tilde
# outputs set expand-tilde on

Details in help bind

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy