1

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:function

or

key:"string to enter"

but when I tried:

key:set .... off

it didn't work.

migrated from serverfault.com May 26 '15 at 14:54

This question came from our site for system and network administrators.

0

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.

Example:

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