# EasyEngine auto complete function ee_single() { for (( j=0; j<${#COMP_WORDS[@]}; j++ )); do for (( i=0; i<${#COMPREPLY[@]}; i++ )); do if [[ ${COMP_WORDS[COMP_CWORD-j]} == ${COMPREPLY[i]} ]]; then rem=( ${COMP_WORDS[COMP_CWORD-j]} ); COMPREPLY=( "${COMPREPLY[@]/$rem}" ) fi done done } function EE_AUTO() { # Get current word local CURRENT=${COMP_WORDS[COMP_CWORD]} # Get previous word local PREVIOUS=${COMP_WORDS[COMP_CWORD-1]} local PREVIOUS2=${COMP_WORDS[COMP_CWORD-2]} local PREVIOUS3=${COMP_WORDS[COMP_CWORD-3]} # List of suggested words case "$PREVIOUS" in # List of suggested words easyengine|ee) COMPREPLY=( $(compgen -W '$(echo clean version help info update import-slow-log; command find /usr/local/lib/easyengine/modules/ -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT) ) return 0 ;; stack) COMPREPLY=( $( compgen -W '$(echo purge status stop start reload restart; command find /usr/local/lib/easyengine/modules/stack -maxdepth 1 -type d -printf "%P " 2> /dev/null)' -- $CURRENT ) ) return 0 ;; install|remove|purge) COMPREPLY=( $( compgen -W '$(echo mail all web mailscanner admin; cd /usr/local/lib/easyengine/modules/stack/install; find -maxdepth 1 -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null; cd /usr/local/lib/easyengine/vendor/; find -type f | grep install | cut -d'_' -f4 | cut -d '.' -f1 2> /dev/null | egrep -v "roundcube|vimbadmin" )' -- $CURRENT ) ) return 0 ;; clean) COMPREPLY=( $( compgen -W '$(echo cd fastcgi memcache opcache all;)' -- $CURRENT ) ) return 0 ;; site) COMPREPLY=( $( compgen -W '$(echo cd create delete disable edit enable info list log show update;)' -- $CURRENT ) ) return 0 ;; list) COMPREPLY=( $( compgen -W "enable available" -- $CURRENT ) ) return 0 ;; info|enable|edit|show|delete|cd|log|update) if [ "$PREVIOUS2" = "site" ]; then COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-available/ -type f -printf "%P " 2> /dev/null)' -- $CURRENT ) ) fi return 0 ;; disable) COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) ) return 0 ;; --wpsubdir|--wpsubdomain) COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) ) return 0 ;; debug) COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) return 0 ;; --nginx|--rewrite|--php|--fpm|--mysql) if [ "$PREVIOUS" = "--mysql" ]; then COMPREPLY=( $(compgen -W '$(echo --import-slow-log-interval; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) else COMPREPLY=( $(compgen -W '$(command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) fi ee_single return 0 ;; --wp) if [ "$PREVIOUS3" = "create" ] || [ "$PREVIOUS3" = "update" ]; then COMPREPLY=( $( compgen -W "--basic --w3tc --wpsc --wpfc" -- $CURRENT ) ) else COMPREPLY=( $(compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null; command cd /usr/local/lib/easyengine/modules/debug/; find -type f | grep debug | grep -v wp | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT) ) ee_single fi return 0 ;; --stop) COMPREPLY=( $( compgen -W '$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null)' -- $CURRENT ) ) ee_single return 0 ;; secure) COMPREPLY=( $( compgen -W '$( cd /usr/local/lib/easyengine/modules/secure; find -type f | grep secure | cut -d'_' -f4 | cut -d '.' -f1 | sed 's/^/--/g' 2> /dev/null)' -- $CURRENT ) ) return 0 ;; *) if [ "$PREVIOUS2" = "create" ]; then COMPREPLY=( $( compgen -W "--html --php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "update" ]; then COMPREPLY=( $( compgen -W "--php --mysql --wp --wpsubdir --wpsubdomain" -- $CURRENT ) ) elif [ "$PREVIOUS2" = "delete" ]; then COMPREPLY=( $( compgen -W "--db --all --files --no-prompt" -- $CURRENT ) ) fi return 0 ;; esac } complete -F EE_AUTO ee easyengine