Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1240: added better support for different names for "python" to…

… django_bash_completion. Thanks, paolo.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4646 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 0e683f6da4165367383db136583a34c3dec99d12 1 parent 4477f50
Jacob Kaplan-Moss authored

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

  1. 24  extras/django_bash_completion
24  extras/django_bash_completion
@@ -31,6 +31,9 @@
31 31
 #
32 32
 # To uninstall, just remove the line from your .bash_profile and .bashrc.
33 33
 
  34
+# Enable extended pattern matching operators.
  35
+shopt -s extglob
  36
+
34 37
 _django_completion()
35 38
 {
36 39
     local cur prev opts actions action_shell_opts action_runfcgi_opts
@@ -58,8 +61,13 @@ _django_completion()
58 61
           ||
59 62
           # python manage.py, /some/path/python manage.py (if manage.py exists)
60 63
           ( ${COMP_CWORD} -eq 2 &&
61  
-            ( $( basename ${COMP_WORDS[0]} ) == python ) &&
  64
+            ( $( basename ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
62 65
             ( $( basename ${COMP_WORDS[1]} ) == manage.py) &&
  66
+            ( -r ${COMP_WORDS[1]} ) ) 
  67
+          ||
  68
+          ( ${COMP_CWORD} -eq 2 &&
  69
+            ( $( basename ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
  70
+            ( $( basename ${COMP_WORDS[1]} ) == django-admin.py) &&
63 71
             ( -r ${COMP_WORDS[1]} ) ) ]] ; then
64 72
 
65 73
         case ${cur} in
@@ -135,3 +143,17 @@ _django_completion()
135 143
 }
136 144
 
137 145
 complete -F _django_completion django-admin.py manage.py
  146
+
  147
+# Support for multiple interpreters.
  148
+unset pythons
  149
+if command -v whereis &>/dev/null; then
  150
+    python_interpreters=$(whereis -b python | cut -d " " -f 2-) 
  151
+    for python in $python_interpreters; do
  152
+        pythons="${pythons} $(basename $python)"
  153
+    done
  154
+    pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
  155
+else
  156
+    pythons=python    
  157
+fi
  158
+
  159
+complete -F _django_completion -o default $pythons

0 notes on commit 0e683f6

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