1

I sometimes want to experiment with Python code in the Python shell. In other languages (Haskell, F#) I'm used to be able to experiment in a REPL that supports command history.

I start the Python shell from (Git) Bash running in Windows Terminal:

$ py
Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+2
3
>>>

How do I repeat the last command, or scroll through the command history?

I'm aware of this question, so I've already tried Alt + p, the arrow keys, and various combinations of those and Ctrl, Shift. Nothing works. Either nothing happens, or Ctrl + n just prints this:

>>> ^N

The arrow keys do work when using the Command Prompt (cmd) in Windows Terminal, but not when using Bash.

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736

0 Answers0