From 26a57e03d2633c9b88bb5d6df478c79efb5849bd Mon Sep 17 00:00:00 2001 From: harshadyeola Date: Sat, 14 Feb 2015 09:25:17 +0530 Subject: [PATCH] better autocompletion --- config/bash_completion.d/ee_auto.rc | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/config/bash_completion.d/ee_auto.rc b/config/bash_completion.d/ee_auto.rc index 3241994d..690c96e5 100644 --- a/config/bash_completion.d/ee_auto.rc +++ b/config/bash_completion.d/ee_auto.rc @@ -29,7 +29,7 @@ _ee_complete() # IF YOU HAD ANOTHER CONTROLLER, YOU'D HANDLE THAT HERE "debug") COMPREPLY=( $(compgen \ - -W "--start --nginx --php --fpm --mysql -i --interactive --stop " \ + -W "$(command find /etc/nginx/sites-enabled/ -type l -printf "%P " 2> /dev/null) --start --nginx --php --fpm --mysql -i --interactive --stop " \ -- $cur) ) ;; @@ -126,20 +126,25 @@ _ee_complete() COMPREPLY=( $(compgen \ -W "--db --files --all" \ -- $cur) ) - + ;; + *) + ;; esac + fi case "$prev" in - "--wpsubdir" | "--wpsubdomain") + "--wp" | "--wpsubdir" | "--wpsubdomain") COMPREPLY=( $(compgen \ -W "--w3tc --wpfc --wpsc" \ -- $cur) ) ;; "--web" | "--admin" | "--mail" | "--nginx" | "--php" | "--mysql" | "--postfix" | "--wpcli" | "--phpmyadmin" | "--adminer" | "--utils" | "--memcache" | "--dovecot") - if [[ ${COMP_WORDS[1]} == "stack" ]]; then + if [[ ${COMP_WORDS[2]} == "install" || ${COMP_WORDS[2]} == "purge" || ${COMP_WORDS[2]} == "remove" ]]; then retlist="--web --admin --mail --nginx --php --mysql --postfix --wpcli --phpmyadmin --adminer --utils --memcache --dovecot" + elif [[ ${COMP_WORDS[2]} == "start" || ${COMP_WORDS[2]} == "reload" || ${COMP_WORDS[2]} == "restart" || ${COMP_WORDS[2]} == "stop" ]]; then + retlist="--nginx --php --mysql --postfix --memcache --dovecot" elif [[ ${COMP_WORDS[1]} == "debug" ]]; then retlist="--start --nginx --php --fpm --mysql -i --interactive --stop" fi @@ -149,7 +154,7 @@ _ee_complete() -- $cur) ) ;; - "--db" | "--files" | "--all") + "--db" | "--files" ) retlist="--db --files --all" ret="${retlist[@]/$prev}" COMPREPLY=( $(compgen \ @@ -157,6 +162,19 @@ _ee_complete() -- $cur) ) ;; + "--all") + if [ ${COMP_WORDS[1]} == "clean" ]; then + retlist="--memcache --opcache --fastcgi" + else + retlist="--db --files" + + fi + ret="${retlist[@]/$prev}" + COMPREPLY=( $(compgen \ + -W "$(echo $ret)" \ + -- $cur) ) + ;; + "--memcache" | "--opcache" | "--fastcgi" | "--all") retlist="--memcache --opcache --fastcgi --all" ret="${retlist[@]/$prev}"