An easy way to re-execute a previously executed command in ipython

In a normal UNIX terminal, $ history It displays the history of commands executed in the past by commands with numbers. And $! ◯◯◯ (command number) You can easily re-execute a previously executed command by typing.

with ipython aaa.png I was running the command like this "I wish I could easily recall past commands like a terminal ..." When I looked it up, I found the command I was looking for, so I'll leave it here as a memorandum.

** 1. Display the history of past commands with numbers **

In[10]: history -g With the above command, you can display the history of past commands with numbers. "-g" is an option that also displays the number. When you run it, it should look like this: aab.png

Find the command you want to re-execute here and check the corresponding command number.

** 2. Call the command you want to re-execute **

ʻIn [11]: recall ◯◯◯ (command number) ` The "recall" command allows you to recall the command corresponding to that number. For example, if you want to execute the 263rd command again now, aac.png I was able to call the command safely.

Only this.

It's very easy. Simply combine the "history" command option "-g" with the "recall" command. Even so, the number of operations and key inputs is a little larger than that of the terminal.

Recommended Posts

An easy way to re-execute a previously executed command in ipython
An easy way to view the time taken in Python and a smarter way to improve it
Easy way to use Wikipedia in Python
[Linux] Command to get a list of commands executed in the past
A clever way to time processing in Python
An easy way to call Java from Python
I made an appdo command to execute a command in the context of the app
Searching for an efficient way to write a Dockerfile in Python with poetry
An easy way to measure the processing speed of a disk recognized by Linux
An easy way to create an import module with jupyter
How to execute a command using subprocess in Python
Fixed a way to force Windows to boot in UEFI
Even beginners can do it! An easy way to write a Sankey Diagram on Plotly
Command line tool to put .gitkeep in an empty directory
A simple way to avoid multiple for loops in Python
Use MeCab to translate sloppy sentences in a "slow" way.
I made a command to generate a table comment in Django
A standard way to develop and distribute packages in Python
How to check if a value exists in an enum
[Python] An easy way to visualize energy data interactively [plotly.express]
Introducing a good way to manage DB connections in Python
How to import NoteBook as a module in Jupyter (IPython)
A relatively easy way to insert a NEologd dictionary on Windows-System Dictionary
Easy way to rename files
[sh] How to store the command execution result in a variable
How to make a string into an array or an array into a string in Python
A game to go on an adventure in python interactive mode
How to get a string from a command line argument in python
How to create a heatmap with an arbitrary domain in Python
How to specify a .py file to load at startup in IPython 0.13
I made a command to display a colorful calendar in the terminal
Easy way to customize Python import
Hit a command in Python (Windows)
In the python command python points to python3.8
Convert a string to an image
An alternative to `pause` in Python
[Python Tutorial] An Easy Introduction to Python
Easy way to enter and execute AtCoder test cases in Jupyter Notebook
Create a command to delete all temporary files generated in a specific folder
I want to color a part of an Excel string in Python
I want to leave an arbitrary command in the command history of Shell
A note I looked up to make a command line tool in Python
What is the fastest way to create a reverse dictionary in python?