Django

Code

Show
Ignore:
Timestamp:
07/20/07 15:49:49 (1 year ago)
Author:
danderson
Message:

schema-evolution: merged trunk:HEAD into schema-evolution branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/extras/django_bash_completion

    r3187 r5734  
    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{ 
     
    4043 
    4144    # Standalone options 
    42     opts="--help --settings --pythonpath --version" 
     45    opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version" 
    4346    # Actions 
    4447    actions="adminindex createcachetable dbshell diffsettings \ 
    45              inspectdb install reset runfcgi runserver \ 
    46              shell sql sqlall sqlclear sqlindexes sqlinitialdata
     48             dumpdata flush inspectdb loaddata reset runfcgi runserver \ 
     49             shell sql sqlall sqlclear sqlcustom sqlflush sqlindexes
    4750             sqlreset sqlsequencereset startapp startproject \ 
    48              syncdb validate" 
     51             syncdb test validate" 
    4952    # Action's options 
    5053    action_shell_opts="--plain" 
     
    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 
     
    7785    else 
    7886        case ${prev} in 
    79             adminindex|install|reset| \ 
    80             sql|sqlall|sqlclear|sqlindexes| \ 
    81             sqlinitialdata|sqlreset|sqlsequencereset) 
    82             # App completion isn't yet implemented, but here's where that 
    83             # would go. 
    84             # COMPREPLY=( $(compgen -W "auth core" -- ${cur}) ) 
    85             COMPREPLY=() 
    86             return 0 
    87             ;; 
     87            adminindex|dumpdata|reset| \ 
     88            sql|sqlall|sqlclear|sqlcustom|sqlindexes| \ 
     89            sqlreset|sqlsequencereset|test) 
     90                # App completion 
     91                settings="" 
     92                # If settings.py in the PWD, use that 
     93                if [ -e settings.py ] ; then 
     94                    settings="$PWD/settings.py" 
     95                else 
     96                    # Use the ENV variable if it is set 
     97                    if [ $DJANGO_SETTINGS_MODULE ] ; then 
     98                        settings=$DJANGO_SETTINGS_MODULE 
     99                    fi 
     100                fi 
     101                # Couldn't find settings so return nothing 
     102                if [ -z $settings ] ; then 
     103                    COMPREPLY=() 
     104                # Otherwise inspect settings.py file 
     105                else 
     106                    apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \ 
     107                          grep -v "django.contrib" |  
     108                          sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \ 
     109                          tr -d "\n"` 
     110                    COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) ) 
     111                fi 
     112                return 0 
     113                ;; 
    88114 
    89115            createcachetable|dbshell|diffsettings| \ 
     
    118144 
    119145complete -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 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