Skip to content
Advertisement

Cycle through ipython “history” with one keystroke per item even when multiple lines

I have a question similar to this one from 2012 IPython – cycle through blocks in input history? – but whose answers are likewise over eight years old. That is: how to cycle through ipython history items without say hitting up-arrow key once per every line in a 30 line block.

Apparently ipython has not used readline for many years: so what is the way (if any) to achieve this ? I am on IPython 7.13.0

Update Hmm just playing around with different key combinations I found that CMD-Up/Down Arrow physically scrolls the cursor through the historical outputs . Below is an approximation that the In[10] is highlighted in yellow briefly after having hit CMD-UpArrow three times from the current In[13]:

enter image description here

It is not the same as my question that is looking to scroll through the historical commands in place /

Advertisement

Answer

This turns out to be specific to the macOS Terminal app handling of PageUp / PageDown. iTerm2 instead has the desired behavior of scrolling the history using those keystrokes.

Two questions remain that I will dig into further:

  • Are there any settings on Terminal app to adjust this behavior
  • What about when using a macBook Pro that does not have PgUp/PgDown` keys?

Update Messing around further with key combinations I found that Shift-[PageUp/PageDn] get the job done on Terminal.app. Well at least that works on an external keyboard. Not sure yet how to achieve that just on the macBook Pro native keyboard. Oh- I need to press Fn-[Up/Dn]arrow

Advertisement