Tuesday, July 22, 2014

Python Auto Completion in Terminal

Auto completion is a nice feature for Terminal commands but inside a Python interpreter it does not work. To enable auto-completion within python interpreter, we need to do the following.

Step 1: Create a file pythonrc at /etc/ directory and add the following lines in the file:
from readline import parse_and_bind
import rlcompleter
parse_and_bind("tab: complete")

Step2:  In the file at /etc/bash.bashrc , add the following line
export PYTHONSTARTUP=/etc/pythonrc

Step3:  Restart the terminal and invoke python interpreter.