Adapt bash readline operate-and-get-next

Lele Gaifax lele at metapensiero.it
Tue Aug 19 04:44:41 EDT 2014


Skip Montanaro <skip at pobox.com> writes:

> Looks reasonable to me, at least if I understand the intent correctly.
> I've never used this functionality in bash (wasn't aware it existed).
> I assume the intention here is to easily re-execute compound
> statements pulled from saved history.

Yes, or any arbitrary sequence of statements/expressions.

> Does your position in the history disappear if you
> operate_and_get_next(), then modify the next recalled input line?

Not sure what you mean with "disappear": basically o-a-g-n "accepts" the
current line (that is, "executes" it, and this means it gets pushed at
the top of history), regardless you edited or not, then fetches the
following input line from the history and presents it to you.

Given these lines in the history:

    >>> a=10
    >>> a-=1
    >>> print(a)
    9

Going back twice, to reach the assignment to "a", and then typing ^O
(bound to o-a-g-n by default) repeatedly, you get:

    >>> a-=1
    >>> print(a)
    8
    >>> a-=1
    >>> print(a)
    7
    >>> a-=1
    >>> print(a)
    6
    >>> a-=1
    >>> print(a)
    5
    >>> a-=1[#]

where the "[#]" is the input cursor.

> When you are finished with a series of Ctl-O
> keystrokes I presume you (as the user) press Ctl-U or Ctl-K to clear
> the input buffer?

Yes.

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list