How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don\'t work. They produce nonsensical characters.
(ve)[kakarukeys@localhost ve]$ python
You didn't specify which environment. Assuming you are using IDLE.
From IDLE documentation: Command history:
Alt-p retrieves previous command matching what you have typed.
Alt-n retrieves next.
(These are Control-p, Control-n on the Mac)
Return while cursor is on a previous command retrieves that command.
Expand word is also useful to reduce typing.
By default use ALT+p for previous command, you can change to Up-Arrow instead in IDLE GUi >> OPtions >> Configure IDLE >>Key >>Custom Key Binding It is not necesary to run a custom script, besides readlines module doesnt run in Windows. Hope That Help. :)
For anaconda for python 3.5, I needed to install ncurses
conda install ncurses
After the ncurses
install tab complete, history, and navigating via left and right arrows worked in the interactive shell.
alt+p
go into options tab
configure idle
Keys
look under history-previous
for the command, you can change it to something you like better once here.
On CentOS, I fix this by
yum install readline-devel
and then recompile python 3.4.
On OpenSUSE, I fix this by
pip3 install readline
Referring to this answer:https://stackoverflow.com/a/26356378/2817654. Perhaps "pip3 install readline" is a general solution. Haven't tried on my CentOS.
Up Arrow works only in Python command line.
In IDLE (Python GUI) the defaults are: Alt-p : retrieves previous command matching what you have typed. Alt-n : retrieves next... In Python 2.7.9 for example, you can see/change the Action Keys selecting: Options -> Configure IDLE -> (Tab) Keys