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
This commit is contained in:
parent
4477f50f0b
commit
0e683f6da4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue