82 | | # App completion isn't yet implemented, but here's where that |
83 | | # would go. |
84 | | # COMPREPLY=( $(compgen -W "auth core" -- ${cur}) ) |
85 | | COMPREPLY=() |
| 82 | # App completion |
| 83 | settings="" |
| 84 | # If settings.py in the PWD, use that |
| 85 | if [ -e settings.py ] ; then |
| 86 | settings="$PWD/settings.py" |
| 87 | else |
| 88 | # Use the ENV variable if it is set |
| 89 | if [ $DJANGO_SETTINGS_MODULE ] ; then |
| 90 | settings=$DJANGO_SETTINGS_MODULE |
| 91 | fi |
| 92 | fi |
| 93 | # Couldn't find settings so return nothing |
| 94 | if [ -z $settings ] ; then |
| 95 | COMPREPLY=() |
| 96 | # Otherwise inspect settings.py file |
| 97 | else |
| 98 | apps=`sed -n "/INSTALLED_APPS = (/,/)/p" $settings | \ |
| 99 | grep -v "django.contrib" | |
| 100 | sed -n "s/^[ ]*'\(.*\.\)*\(.*\)'.*$/\2 /pg" | \ |
| 101 | tr -d "\n"` |
| 102 | COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) ) |
| 103 | fi |