help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Readline macro question


From: Chet Ramey
Subject: Re: Readline macro question
Date: Mon, 1 Aug 2022 15:17:43 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

On 7/29/22 6:44 PM, Robert E. Griffith wrote:
Thanks Koichi Murase,  This opens up a whole new set of possibilities for me. For some reason I thought -x only executed external commands and I would not be able to change the environment.

Is there a way to get readline to return from inside the rl_print_line_and_clear function? Like simulating a \n? I tried appending a \n to READLINE_LINE but that did not cause it to return

That has the same effect as if you had entered ^V^M. Adding a character to
the line buffer does not make it appear in readline's input.


If not, I think I can use a macro that invokes a shell function and then has a \C-m to tell readline to return.

That is the most common idiom. You use a macro that contains the key
sequences you want to appear on readline's input, exactly as if they had
been read from the keyboard. If you bind a key sequence to a shell
command using `bind -x', you need to put that key sequence in the macro.

I can only invoke a readline function from within a macro string if that function has a keyseq bound to it?

Yes, there is no other way to invoke a bindable readline command.

    $ bind -x '"<someObscureKey>": fooFn'
    $ bind '"\eOP": "<someObscureKey>\C-m"'

Exactly.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]