Code

Ticket #1240: app_completion.diff

File app_completion.diff, 889 bytes (added by Rob Hudson <treborhudson@…>, 7 years ago)

Adding app completion to existing bash script using standard unix tools (sed, grep, tr).

Line 
1Index: extras/django_bash_completion
2===================================================================
3--- extras/django_bash_completion       (revision 4557)
4+++ extras/django_bash_completion       (working copy)
5@@ -79,10 +79,12 @@
6             adminindex|install|reset| \
7             sql|sqlall|sqlclear|sqlindexes| \
8             sqlinitialdata|sqlreset|sqlsequencereset)
9-            # App completion isn't yet implemented, but here's where that
10-            # would go.
11-            # COMPREPLY=( $(compgen -W "auth core" -- ${cur}) )
12-            COMPREPLY=()
13+            # App completion
14+            apps=`sed -n '/INSTALLED_APPS = (/,/)/p' settings.py | \
15+                  grep -v django |
16+                  sed -n "s/^[ ]*'.*\.\(.*\)'.*$/\1 /pg" | \
17+                  tr -d '\n'`
18+            COMPREPLY=( $(compgen -W "${apps}" -- ${cur}) )
19             return 0
20             ;;
21