99
1010 # Get Previous Word
1111 local PREVIOUS=${COMP_WORDS[COMP_CWORD-1]}
12-
13- # Use Word Twice In Auto Completion
14- local EECOMMON=${COMP_WORDS[COMP_CWORD-2]}
12+ local PREVIOUS2=${COMP_WORDS[COMP_CWORD-2]}
13+ local PREVIOUS3=${COMP_WORDS[COMP_CWORD-3]}
1514
1615 # List Of Suggested Words
1716 case "$PREVIOUS" in
@@ -32,92 +31,97 @@ EEAUTO()
3231 return 0
3332 ;;
3433
35- debug )
36- COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --mysql --wp --stop " -- $CURRENT) )
34+ site )
35+ COMPREPLY=( $( compgen -W "list show info create enable disable delete edit " -- $CURRENT ) )
3736 return 0
3837 ;;
3938
40- --nginx )
41- COMPREPLY=( $(compgen -W "--rewrite --php --fpm --mysql --wp --stop " -- $CURRENT) )
39+ list )
40+ COMPREPLY=( $( compgen -W "enable available " -- $CURRENT ) )
4241 return 0
4342 ;;
4443
45- --rewrite )
46- COMPREPLY=( $(compgen -W "--nginx --php --fpm --mysql --wp --stop" -- $CURRENT) )
44+ show|delete|--stop )
45+ COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) )
4746 return 0
4847 ;;
4948
50- --php)
51- COMPREPLY=( $(compgen -W "--nginx --rewrite --fpm --mysql --wp --stop" -- $CURRENT) )
49+ info|enable)
50+ if [ "$PREVIOUS2" = "site" ]
51+ then
52+ COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) )
53+ fi
5254 return 0
5355 ;;
5456
55- --fpm)
56- COMPREPLY=( $(compgen -W "--nginx --rewrite --php --mysql --wp --stop" -- $CURRENT) )
57+ edit)
58+ if [ "$PREVIOUS2" = "site" ]
59+ then
60+ COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) )
61+ fi
5762 return 0
5863 ;;
5964
60- --mysql )
61- COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --wp --stop" -- $CURRENT) )
65+ disable )
66+ COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2>/dev/null)' -- $CURRENT ) )
6267 return 0
6368 ;;
6469
65- --wp )
66- COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --mysql --stop " -- $CURRENT) )
70+ --wpsubdir|--wpsubdomain )
71+ COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc " -- $CURRENT ) )
6772 return 0
6873 ;;
6974
70- site )
71- COMPREPLY=( $( compgen -W "list show info create enable disable delete edit " -- $CURRENT ) )
75+ debug )
76+ COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --mysql --wp --stop " -- $CURRENT) )
7277 return 0
7378 ;;
7479
75- list )
76- COMPREPLY=( $( compgen -W "enable available " -- $CURRENT ) )
80+ --nginx )
81+ COMPREPLY=( $(compgen -W "--rewrite --php --fpm --mysql --wp --stop " -- $CURRENT) )
7782 return 0
7883 ;;
7984
80- show|enable|delete|--stop )
81- COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) )
85+ --rewrite )
86+ COMPREPLY=( $(compgen -W "--nginx --php --fpm --mysql --wp --stop" -- $CURRENT) )
8287 return 0
8388 ;;
8489
85- info)
86- if [ "$EECOMMON" = "site" ]
87- then
88- COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) )
89- fi
90+ --php)
91+ COMPREPLY=( $(compgen -W "--nginx --rewrite --fpm --mysql --wp --stop" -- $CURRENT) )
9092 return 0
9193 ;;
92- edit)
93- if [ "$EECOMMON" = "site" ]
94- then
95- COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2>/dev/null)' -- $CURRENT ) )
96- fi
94+
95+ --fpm)
96+ COMPREPLY=( $(compgen -W "--nginx --rewrite --php --mysql --wp --stop" -- $CURRENT) )
9797 return 0
9898 ;;
9999
100- disable )
101- COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2>/dev/null)' -- $CURRENT ) )
100+ --mysql )
101+ COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --wp --stop" -- $CURRENT) )
102102 return 0
103103 ;;
104104
105- --wp|--wpsubdir|--wpsubdomain)
106- COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) )
105+ --wp)
106+ if [ "$PREVIOUS3" = "create" ]
107+ then
108+ COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) )
109+ else
110+ COMPREPLY=( $(compgen -W "--nginx --rewrite --php --fpm --mysql --stop" -- $CURRENT) )
111+ fi
107112 return 0
108113 ;;
109114
110115 *)
111- if [ "$EECOMMON " = "create" ]
116+ if [ "$PREVIOUS2 " = "create" ]
112117 then
113118 COMPREPLY=( $( compgen -W "--html --php --wp --wpsubdir --wpsubdomain" -- $CURRENT ) )
114- elif [ "$EECOMMON " = "delete" ]
119+ elif [ "$PREVIOUS2 " = "delete" ]
115120 then
116121 COMPREPLY=( $( compgen -W "--db --all --files" -- $CURRENT ) )
117122 fi
118123 return 0
119124 ;;
120-
121125 esac
122126}
123127
0 commit comments