Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #12174 -- Corrected Bash command line completion when calling "…

…python manage.py". Thanks to sethp for the report, and SmileyChris for the initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12386 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 174352991231bedc9a7e68440509f40a14292e78 1 parent 8600ad4
Russell Keith-Magee authored February 05, 2010

Showing 1 changed file with 33 additions and 1 deletion. Show diff stats Hide diff stats

  1. 34  extras/django_bash_completion
34  extras/django_bash_completion
@@ -37,4 +37,36 @@ _django_completion()
37 37
                    COMP_CWORD=$COMP_CWORD \
38 38
 	               DJANGO_AUTO_COMPLETE=1 $1 ) )
39 39
 }
40  
-complete -F _django_completion -o default django-admin.py manage.py
  40
+complete -F _django_completion -o default django-admin.py manage.py django-admin
  41
+
  42
+_python_django_completion()
  43
+{
  44
+    if [[ ${COMP_CWORD} -ge 2 ]]; then
  45
+        PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
  46
+        echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
  47
+        if [[ $? == 0 ]]; then
  48
+            PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
  49
+            echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
  50
+            if [[ $? == 0 ]]; then
  51
+                COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
  52
+                               COMP_CWORD=$(( COMP_CWORD-1 )) \
  53
+                               DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
  54
+            fi
  55
+        fi
  56
+    fi
  57
+}
  58
+
  59
+# Support for multiple interpreters.
  60
+unset pythons
  61
+if command -v whereis &>/dev/null; then
  62
+    python_interpreters=$(whereis python | cut -d " " -f 2-)
  63
+    for python in $python_interpreters; do
  64
+        pythons="${pythons} $(basename -- $python)"
  65
+    done
  66
+    pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
  67
+else
  68
+    pythons=python
  69
+fi
  70
+
  71
+complete -F _python_django_completion -o default $pythons
  72
+

0 notes on commit 1743529

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