Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@freakboy3742 freakboy3742 authored
Showing with 33 additions and 1 deletion.
  1. +33 −1 extras/django_bash_completion
View
34 extras/django_bash_completion
@@ -37,4 +37,36 @@ _django_completion()
COMP_CWORD=$COMP_CWORD \
DJANGO_AUTO_COMPLETE=1 $1 ) )
}
-complete -F _django_completion -o default django-admin.py manage.py
+complete -F _django_completion -o default django-admin.py manage.py django-admin
+
+_python_django_completion()
+{
+ if [[ ${COMP_CWORD} -ge 2 ]]; then
+ PYTHON_EXE=$( basename -- ${COMP_WORDS[0]} )
+ echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ PYTHON_SCRIPT=$( basename -- ${COMP_WORDS[1]} )
+ echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
+ if [[ $? == 0 ]]; then
+ COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
+ COMP_CWORD=$(( COMP_CWORD-1 )) \
+ DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
+ fi
+ fi
+ fi
+}
+
+# Support for multiple interpreters.
+unset pythons
+if command -v whereis &>/dev/null; then
+ python_interpreters=$(whereis 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 _python_django_completion -o default $pythons
+
Please sign in to comment.
Something went wrong with that request. Please try again.