Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@jacobian jacobian authored
Showing with 23 additions and 1 deletion.
  1. +23 −1 extras/django_bash_completion
View
24 extras/django_bash_completion
@@ -31,6 +31,9 @@
#
# To uninstall, just remove the line from your .bash_profile and .bashrc.
+# Enable extended pattern matching operators.
+shopt -s extglob
+
_django_completion()
{
local cur prev opts actions action_shell_opts action_runfcgi_opts
@@ -58,8 +61,13 @@ _django_completion()
||
# python manage.py, /some/path/python manage.py (if manage.py exists)
( ${COMP_CWORD} -eq 2 &&
- ( $( basename ${COMP_WORDS[0]} ) == python ) &&
+ ( $( basename ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
( $( basename ${COMP_WORDS[1]} ) == manage.py) &&
+ ( -r ${COMP_WORDS[1]} ) )
+ ||
+ ( ${COMP_CWORD} -eq 2 &&
+ ( $( basename ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
+ ( $( basename ${COMP_WORDS[1]} ) == django-admin.py) &&
( -r ${COMP_WORDS[1]} ) ) ]] ; then
case ${cur} in
@@ -135,3 +143,17 @@ _django_completion()
}
complete -F _django_completion django-admin.py manage.py
+
+# Support for multiple interpreters.
+unset pythons
+if command -v whereis &>/dev/null; then
+ python_interpreters=$(whereis -b python | cut -d " " -f 2-)
+ for python in $python_interpreters; do
+ pythons="${pythons} $(basename $python)"
+ done
+ pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
+else
+ pythons=python
+fi
+
+complete -F _django_completion -o default $pythons
Please sign in to comment.
Something went wrong with that request. Please try again.