Skip to content

Commit

Permalink
Fixed django#1240: added better support for different names for "pyth…
Browse files Browse the repository at this point in the history
…on" 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
jacobian committed Feb 28, 2007
1 parent 4477f50 commit 0e683f6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion extras/django_bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 0e683f6

Please sign in to comment.