This is an extension to:
I am looking for a way (through
readline) to bind a key to a shell function, which modifies the current command line. Possibly through the
For example, if this is the current command line (
$ is the prompt and
| is my cursor)
$ command_foo arg_foo foo|
Then have my shell function replace all of my
bar's, after I press the key that the function is bound to.
I would then expect the command line to read (I don't really care where the new cursor position will be)
$ command_bar arg_bar bar
Of course I can fine tune my function so that only the last
foo is replaced by
bar, but that's details.
Is there anyway to achieve this via
readline, possibly utilizing the
$BASH_COMMAND shell variable?