- Timestamp:
- 07/20/07 15:49:49 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/schema-evolution/extras/django_bash_completion
r3187 r5734 32 32 # To uninstall, just remove the line from your .bash_profile and .bashrc. 33 33 34 # Enable extended pattern matching operators. 35 shopt -s extglob 36 34 37 _django_completion() 35 38 { … … 40 43 41 44 # Standalone options 42 opts="--help --settings --pythonpath -- version"45 opts="--help --settings --pythonpath --noinput --noreload --format --indent --verbosity --adminmedia --version" 43 46 # Actions 44 47 actions="adminindex createcachetable dbshell diffsettings \ 45 inspectdb installreset runfcgi runserver \46 shell sql sqlall sqlclear sql indexes sqlinitialdata\48 dumpdata flush inspectdb loaddata reset runfcgi runserver \ 49 shell sql sqlall sqlclear sqlcustom sqlflush sqlindexes \ 47 50 sqlreset sqlsequencereset startapp startproject \ 48 syncdb validate"51 syncdb test validate" 49 52 # Action's options 50 53 action_shell_opts="--plain" … … 59 62 # python manage.py, /some/path/python manage.py (if manage.py exists) 60 63 ( ${COMP_CWORD} -eq 2 && 61 ( $( basename ${COMP_WORDS[0]} ) == python ) &&64 ( $( basename ${COMP_WORDS[0]} ) == python?([1-9]\.[0-9]) ) && 62 65 ( $( 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) && 63 71 ( -r ${COMP_WORDS[1]} ) ) ]] ; then 64 72 … … 77 85 else 78 86 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 ;; 88 114 89 115 createcachetable|dbshell|diffsettings| \ … … 118 144 119 145 complete -F _django_completion django-admin.py manage.py 146 147 # Support for multiple interpreters. 148 unset pythons 149 if 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" " ") 155 else 156 pythons=python 157 fi 158 159 complete -F _django_completion -o default $pythons
