Sherwood Wang
Sherwood Wang

Reputation: 715

Read input within the command bound to a key in bash

How can I read input within the command bound to a key?

I've tried:

bind -x '"\C-b":read x'

After Control-b hitted, bash hangs.

Upvotes: 0

Views: 63

Answers (1)

chepner
chepner

Reputation: 531095

bind -x isn't designed to run interactive commands; it should only be used to run commands that produce output, then exit back to the shell. Also, read x would be executed in a subshell invoked by readline, so whatever value you input to set x would be lost when the subshell exits.

Upvotes: 1

Related Questions