About
Command history management
Articles Related
Management
Location
By default, the history file is named .ipython/profile_name/history.sqlite
Arrow
- up- and down-arrow keys
- or Ctrl-p and Ctrl-n
Search
- Ctrl-r
Variable In and out
- Input and output history are kept in variables called In and Out, keyed by the prompt numbers, e.g. In[4].
In?
Type: list
String form: ['', "print('Hello IPython')", '21 * 2', "def say_hello(name):\n print('Hello {name}'.format(n <...> = range(10000)', 'max(x)')", "get_ipython().magic('lsmagic')", "get_ipython().magic('pinfo In')"]
Length: 12
Docstring:
list() -> new empty list
list(iterable) -> new list initialized from iterable's items
Shortcut variable
- The last three objects in output history are also kept in variables named _, and _.
Magic
- %history magic function can examine past input and output.
- %edit, %rerun, %recall, %macro, %save and %pastebin can use history input:
%pastebin 3 18-20 ~1/1-5
This will take line 3 and lines 18 to 20 from the current session, and lines 1-5 from the previous session.