Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I was just reading the readline man-page and disovered a bunch of great commands I didn't know about. However, several don't have default key bindings. Is there a way to execute the unbound commands from the shell?

I'm not asking how to bind the command in ~/.inputrc, but instead how to execute it as a "one off" from the shell or in a bash script.

For example, the "dump-variables" command. Is there some command I can feed "dump-variables" to as an argument to have it executed?

NOTE: Originally, posted on Server Fault, but advised to repost here.

share|improve this question
1  
I don't think there is, from a quick glance at the readline manual and source. –  Jim Paris Oct 22 '12 at 18:57

1 Answer 1

I believe what you are looking for is the bind command itself. According to man builtin information running bind <readline-command> allows you to run one-offs, however, I couldn't get it to work like the manual says it should...it kept making keys not work for me; your mileage may vary. I did find the following commands which may be of use to you.

bind -p # Equivalent to dump-functions [machine readable]
bind -P # Equivalent to dump-functions [human readable]

bind -s # Equivalent to dump-macros    [machine readable]
bind -S # Equivalent to dump-macros    [human readable]

bind -v # Equivalent to dump-variables [machine readable]
bind -V # Equivalent to dump-variables [human readable]

Edit Note I would like to point out how annoying it is that it doesn't work like the manual says it should because if you type in bind and then press tab for auto-complete, it shows all of the commands.

share|improve this answer
    
Re directly calling readline functions: I don't think the manual actually claims that you can do that; in case you're referring to the syntax form bind readline-command: I suspect command there stands for a definition (mapping) line, not a directly callable readline function. The auto-completion is a nicety explicitly preconfigured on some platforms (e.g., Fedora 20), but not on many others; its presence does NOT imply that you can call readline functions directly - it's a fairly "dumb" command-completion spec: the completion works on any argument supplied to bind. –  mklement0 Jul 17 at 22:09
1  
+1 for the commands to list functions/macros/variables in effect; it's worth adding -X for shell commands (defined via -x). –  mklement0 Jul 17 at 22:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.