I’ve gone a surprisingly long time not knowing this, but python (the interactive shell) has an rc file it can read on startup. This means you can preload commonly used modules such as sys and os as well as spice things up a bit by doing an import readline which will automatically add the sorely-missing readline capabilities to the python interactive shell.
It’s pretty easy to set up:
- add export PYTHONSTARTUP=~/.python to your ~/.bashrc
- add import sys, os, readline to ~/.python
- …
- PROFIT!!
For bonus points, you can also add set editing-mode vi to your ~/.inputrc to enable vi key bindings. Note that on OSX this will also require installing the GNU readline compatible version of the readline module (available here).