Adapt bash readline operate-and-get-next

Lele Gaifax lele at metapensiero.it
Tue Aug 19 09:10:54 EDT 2014


Skip Montanaro <skip at pobox.com> writes:

> On Tue, Aug 19, 2014 at 3:44 AM, Lele Gaifax <lele at metapensiero.it> wrote:
>> Given these lines in the history:
>>
>>     >>> a=10
>>     >>> a-=1
>>     >>> print(a)
>>     9
>
> Suppose you have the above, as you indicated. Ctl-P your way back to
> the a=10 line. Press Ctl-O. It executes that assignment and fills the
> input buffer with "a-=1". Instead of just pressing Ctl-O, type a "1"
> first, changing the input buffer to "a-=11". *Now* press Ctl-O. I
> assume it executes that statement. You've edited the line, however.
> Does it present you with the print statement or not?

Yes, it presents the print statement. Another Ctrl-O will present
"a-=11" again, and so on.

> I guess I could have answered my own question using bash:
>
> firefly% a=10
> firefly% a='a'
> firefly% echo $a
> a
> firefly% a=10
> firefly% a='b'
> firefly% echo $a
> b
>
> The second batch of three lines were executed from history with this
> key sequence:
>
> Ctl-P Ctl-P Ctl-P Ctl-O DEL DEL b ' Ctl-O RET
>
> That's pretty cool. Even if I never live to see it in Python (I'm
> still using 2.7), I will definitely start using it in bash. :-)

Yes, it's very handy indeed!

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