Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IPython how to print last n commands?

Tags:

ipython

I am using IPython 2.7. I wish to print last 3 or 5 or in general 'n' commands. The %hist command prints all the commands till now. Note, here, by 'n' I do not refer to line numberings (i.e. IPython's indexing of each line).

like image 996
jaydeepsb Avatar asked Dec 14 '22 20:12

jaydeepsb


1 Answers

To get the last 5 commands:

%hist -l 5

You can see all the arguments that %hist supports by typing %history?.

like image 195
Daniel Avatar answered Dec 26 '22 18:12

Daniel