Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added completetion support for app names to django_base_completion, w…

…hich closes #1240. Thanks for the patch, Rob Hudson

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4575 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0a2155e5b3bf44f44b1a274a269c07af0bd58f33 1 parent 3468fd0
Jacob Kaplan-Moss jacobian authored
Showing with 22 additions and 4 deletions.
  1. +22 −4 extras/django_bash_completion
26 extras/django_bash_completion
View
@@ -79,10 +79,28 @@ _django_completion()
adminindex|install|reset| \
sql|sqlall|sqlclear|sqlindexes| \
sqlinitialdata|sqlreset|sqlsequencereset)
- # App completion isn't yet implemented, but here's where that
- # would go.
- # COMPREPLY=( $(compgen -W "auth core" -- ${cur}) )
- COMPREPLY=()
+ # App completion
+ settings=""
+ # If settings.py in the PWD, use that
+ if [ -e settings.py ] ; then
+ settings="$PWD/settings.py"
+ else
+ # Use the ENV variable if it is set
+ if [ $DJANGO_SETTINGS_MODULE ] ; then
+ settings=$DJANGO_SETTINGS_MODULE
+ fi
+ fi
+ # Couldn't find settings so return nothing
+ if [ -z $settings ] ; then
+ COMPREPLY=()
+ # Otherwise inspect settings.py file
+ else
+ apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \
+ grep -v "django.contrib" |
+ sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \
+ tr -d "\n"`
+ COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) )
+ fi
return 0
;;
Please sign in to comment.
Something went wrong with that request. Please try again.