How to view the entire history of Python commands in the Mac terminal

Viewed 369

Is there a way to view the entire command history of Python, from the point of the first command 'python' after the installation, in the Mac terminal?

UPDATE: So, it is not possible to retrieve command history from python in the mac terminal. The best solution was proposed by BobStein-VisiBone in how do you see the entire command history in interactive python? where he mentions using iPython. Unfortunately, even that won't help retrieve the history of the commands that were input in the terminal before setting up iPython. In other words, those commands are probably gone for good.

1 Answers

You can try:

history | grep "^[^a-zA-Z]*python *"

This will print out your terminal history of all commands that start with python

Related