Ticket #19806: Remove-completion-of-python-manage.py.patch

File Remove-completion-of-python-manage.py.patch, 2.1 KB (added by Anders Kaseorg, 10 years ago)
  • extras/django_bash_completion

    From 882b3b573f7406dc68a69297684bb9399087346a Mon Sep 17 00:00:00 2001
    From: Anders Kaseorg <andersk@mit.edu>
    Date: Sun, 24 Feb 2013 17:25:31 -0500
    Subject: [PATCH] Fixed #19806 -- Remove completion of python manage.py
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    Trying to add completion for ‘python manage.py’ resulted in the
    upstream completion hook for ‘python’ being entirely clobbered, which
    is really unfriendly.  Revert this until bash-completion provides a
    good way to hook subcommands.
    
    (Reopens #12174.)
    
    Signed-off-by: Anders Kaseorg <andersk@mit.edu>
    ---
     extras/django_bash_completion | 31 -------------------------------
     1 file changed, 31 deletions(-)
    
    diff --git a/extras/django_bash_completion b/extras/django_bash_completion
    index 3e02d8e..2ddf7ed 100755
    a b _django_completion()  
    3838                   DJANGO_AUTO_COMPLETE=1 $1 ) )
    3939}
    4040complete -F _django_completion -o default django-admin.py manage.py django-admin
    41 
    42 _python_django_completion()
    43 {
    44     if [[ ${COMP_CWORD} -ge 2 ]]; then
    45         PYTHON_EXE=${COMP_WORDS[0]##*/}
    46         echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1
    47         if [[ $? == 0 ]]; then
    48             PYTHON_SCRIPT=${COMP_WORDS[1]##*/}
    49             echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1
    50             if [[ $? == 0 ]]; then
    51                 COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \
    52                                COMP_CWORD=$(( COMP_CWORD-1 )) \
    53                                DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) )
    54             fi
    55         fi
    56     fi
    57 }
    58 
    59 # Support for multiple interpreters.
    60 unset pythons
    61 if command -v whereis &>/dev/null; then
    62     python_interpreters=$(whereis python | cut -d " " -f 2-)
    63     for python in $python_interpreters; do
    64         pythons="${pythons} ${python##*/}"
    65     done
    66     pythons=$(echo $pythons | tr " " "\n" | sort -u | tr "\n" " ")
    67 else
    68     pythons=python
    69 fi
    70 
    71 complete -F _python_django_completion -o default $pythons
Back to Top