help-bash
[Top][All Lists]
Advanced

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

Re: Repeat last n commands


From: Dennis Williamson
Subject: Re: Repeat last n commands
Date: Mon, 27 Sep 2021 10:32:37 -0500

On Mon, Sep 27, 2021, 9:41 AM Julius Hamilton <juliushamilton100@gmail.com>
wrote:

> Hey,
>
> Sometimes I am writing a method in a live Python shell (respectively in
> Termux, which uses Bash) and I make a mistake and the method definition is
> cancelled and I'd like to redo all executed lines up to the erroneous one.
>
> I believe that the ability to re-execute the last n lines would be part of
> bash rather than Python, is that correct?
>
> Is there any such command?
>
> Thanks very much,
> Julius
>

Bash doesn't have a role in the Python REPL but Readline does. If you use
the technique outlined here:

https://medium.com/@oalejel/printing-command-history-within-the-python-interactive-terminal-repl-simplified-5fd202c64880

you can display lines from the REPL history and copy/paste them to have
them replayed.

Note that some Python shells work differently or may need to have Readline
enabled.

>


reply via email to

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