Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 authored February 25, 2007

Showing 1 changed file with 22 additions and 4 deletions. Show diff stats Hide diff stats

  1. 26  extras/django_bash_completion
26  extras/django_bash_completion
@@ -79,10 +79,28 @@ _django_completion()
79 79
             adminindex|install|reset| \
80 80
             sql|sqlall|sqlclear|sqlindexes| \
81 81
             sqlinitialdata|sqlreset|sqlsequencereset)
82  
-            # App completion isn't yet implemented, but here's where that
83  
-            # would go.
84  
-            # COMPREPLY=( $(compgen -W "auth core" -- ${cur}) )
85  
-            COMPREPLY=()
  82
+            # App completion
  83
+            settings=""
  84
+            # If settings.py in the PWD, use that
  85
+            if [ -e settings.py ] ; then
  86
+                settings="$PWD/settings.py"
  87
+            else
  88
+                # Use the ENV variable if it is set
  89
+                if [ $DJANGO_SETTINGS_MODULE ] ; then
  90
+                    settings=$DJANGO_SETTINGS_MODULE
  91
+                fi
  92
+            fi
  93
+            # Couldn't find settings so return nothing
  94
+            if [ -z $settings ] ; then
  95
+                COMPREPLY=()
  96
+            # Otherwise inspect settings.py file
  97
+            else
  98
+                apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \
  99
+                      grep -v "django.contrib" | 
  100
+                      sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \
  101
+                      tr -d "\n"`
  102
+                COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) )
  103
+            fi
86 104
             return 0
87 105
             ;;
88 106
 

0 notes on commit 0a2155e

Please sign in to comment.
Something went wrong with that request. Please try again.