Ticket #1240: support_for_multiple_interpreters.diff

File support_for_multiple_interpreters.diff, 1.6 KB (added by paolo <paolo@…>, 17 years ago)

Updated patch against the trunk

  • django_bash_completion

     
    3131#
    3232# To uninstall, just remove the line from your .bash_profile and .bashrc.
    3333
     34# Enable extended pattern matching operators.
     35shopt -s extglob
     36
    3437_django_completion()
    3538{
    3639    local cur prev opts actions action_shell_opts action_runfcgi_opts
     
    5861          ||
    5962          # python manage.py, /some/path/python manage.py (if manage.py exists)
    6063          ( ${COMP_CWORD} -eq 2 &&
    61             ( $( basename ${COMP_WORDS[0]} ) == python ) &&
     64            ( $( basename ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) &&
    6265            ( $( 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) &&
    6371            ( -r ${COMP_WORDS[1]} ) ) ]] ; then
    6472
    6573        case ${cur} in
     
    135143}
    136144
    137145complete -F _django_completion django-admin.py manage.py
     146
     147# Support for multiple interpreters.
     148unset pythons
     149if 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" " ")
     155else
     156    pythons=python   
     157fi
     158
     159complete -F _django_completion -o default $pythons
Back to Top