Skip to content

Commit 5908fde

Browse files
authored
document %history usage with all lines of a session (ipython#15069)
Hello IPython team, This tiny PR aims to make to easier to read the usage doc of the [%history](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-history) magic. Presently, usage examples for the `range` arguments are: ``` ``4`` Line 4, current session ``4-6`` Lines 4-6, current session ``243/1-5`` Lines 1-5, session 243 ``~2/7`` Line 7, session 2 before current ``~8/1-~6/5`` From the first line of 8 sessions ago, to the fifth line of 6 sessions ago. ``` While I was trying to print all lines from a past session, I got the feeling that the case of how to print all lines of a session is not obviously documented (i.e. it took me 2-3 trials to get the result correctly). In this PR, I propose to add to 3rd position (between ``4-6`` and ``243/1-5``): ``` ``~2/`` All lines of session 2 before current ``` Then I removed the case ``~2/7`` because it's redundant with the new ``~2/`` + the existing ``243/1-5``, I believe.
2 parents b24d8da + 639aa56 commit 5908fde

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

IPython/core/magics/history.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ def history(self, parameter_s = ''):
121121
Line 4, current session
122122
``4-6``
123123
Lines 4-6, current session
124+
``~2/``
125+
All lines of session 2 before current
124126
``243/1-5``
125127
Lines 1-5, session 243
126-
``~2/7``
127-
Line 7, session 2 before current
128128
``~8/1-~6/5``
129129
From the first line of 8 sessions ago, to the fifth line of 6
130130
sessions ago.

0 commit comments

Comments
 (0)