Django Bash Shell Completion

By | January 10, 2010

Django includes a Bash shell completion script, which can save a lot of time. The tutorial recommends installing it, but doesn’t explain how. Fortunately, its the same as for any other Bash shell completion script. Here’s how I did it for Django.

  • Add an environment variable for the location where you installed Django. For example, add the following line to ~/.bash_profile:
    export DJANGO_HOME=/Users/rstewart/code/Django-1.1.1
  • Add a line after this one in ~/.bash_profile to read the script, e.g.,
    source $DJANGO_HOME/extras/django_bash_completion
  • After saving .bash_profile, open a new terminal or run source ~/.bash_profile

Now, you can press tab to complete commands. Below, I pressed tab after entering “manage.py”.

$ python manage.py
compilemessages   diffsettings      loaddata          runserver         sqlclear          sqlreset          syncdb
createcachetable  dumpdata          makemessages      shell             sqlcustom         sqlsequencereset  test
createsuperuser   flush             reset             sql               sqlflush          startapp          validate
dbshell           inspectdb         runfcgi           sqlall            sqlindexes        startproject

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.