diff --git a/extras/django_bash_completion b/extras/django_bash_completion
index 8f85211..9d77622 100755
a
|
b
|
|
31 | 31 | # |
32 | 32 | # To uninstall, just remove the line from your .bash_profile and .bashrc. |
33 | 33 | |
| 34 | _copied_from_python() |
| 35 | { |
| 36 | local cur prev words cword |
| 37 | _init_completion || return |
| 38 | |
| 39 | case $prev in |
| 40 | -'?'|-h|--help|-V|--version|-c|-m) |
| 41 | return 0 |
| 42 | ;; |
| 43 | -Q) |
| 44 | COMPREPLY=( $( compgen -W "old new warn warnall" -- "$cur" ) ) |
| 45 | return 0 |
| 46 | ;; |
| 47 | -W) |
| 48 | COMPREPLY=( $( compgen -W "ignore default all module once error" \ |
| 49 | -- "$cur" ) ) |
| 50 | return 0 |
| 51 | ;; |
| 52 | !(?(*/)python*([0-9.])|-?)) |
| 53 | [[ $cword -lt 2 || ${words[cword-2]} != -@(Q|W) ]] \ |
| 54 | && _filedir |
| 55 | ;; |
| 56 | esac |
| 57 | |
| 58 | |
| 59 | # if '-c' is already given, complete all kind of files. |
| 60 | local i |
| 61 | for (( i=0; i < ${#words[@]}-1; i++ )); do |
| 62 | if [[ ${words[i]} == -c ]]; then |
| 63 | _filedir |
| 64 | fi |
| 65 | done |
| 66 | |
| 67 | |
| 68 | if [[ "$cur" != -* ]]; then |
| 69 | _filedir 'py?([co])' |
| 70 | else |
| 71 | COMPREPLY=( $( compgen -W '$( _parse_help "$1" -h )' -- "$cur" ) ) |
| 72 | fi |
| 73 | |
| 74 | return 0 |
| 75 | } |
| 76 | |
34 | 77 | _django_completion() |
35 | 78 | { |
36 | 79 | COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]}" \ |
… |
… |
complete -F _django_completion -o default django-admin.py manage.py django-admin
|
41 | 84 | |
42 | 85 | _python_django_completion() |
43 | 86 | { |
44 | | if [[ ${COMP_CWORD} -ge 2 ]]; then |
| 87 | if [[ ${COMP_CWORD} -ge 1 ]]; then |
45 | 88 | PYTHON_EXE=${COMP_WORDS[0]##*/} |
46 | 89 | echo $PYTHON_EXE | egrep "python([2-9]\.[0-9])?" >/dev/null 2>&1 |
47 | 90 | 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[*]} ) ) |
| 91 | if [[ ${COMP_CWORD} -ge 2 ]]; then |
| 92 | PYTHON_SCRIPT=${COMP_WORDS[1]##*/} |
| 93 | echo $PYTHON_SCRIPT | egrep "manage\.py|django-admin(\.py)?" >/dev/null 2>&1 |
| 94 | if [[ $? == 0 ]]; then |
| 95 | COMPREPLY=( $( COMP_WORDS="${COMP_WORDS[*]:1}" \ |
| 96 | COMP_CWORD=$(( COMP_CWORD-1 )) \ |
| 97 | DJANGO_AUTO_COMPLETE=1 ${COMP_WORDS[*]} ) ) |
| 98 | else |
| 99 | _copied_from_python $* |
| 100 | fi |
| 101 | else |
| 102 | _copied_from_python $* |
54 | 103 | fi |
55 | 104 | fi |
56 | 105 | fi |