diff --git a/completion/available/bash-it.completion.bash b/completion/available/bash-it.completion.bash index 68d067c8..43a26a64 100644 --- a/completion/available/bash-it.completion.bash +++ b/completion/available/bash-it.completion.bash @@ -51,10 +51,10 @@ _bash-it-comp() COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - + chose_opt="${COMP_WORDS[1]}" + file_type="${COMP_WORDS[2]}" opts="help show enable disable" - - case "${prev}" in + case "${chose_opt}" in show) local show_args="plugins aliases completions" COMPREPLY=( $(compgen -W "${show_args}" -- ${cur}) ) @@ -65,13 +65,30 @@ _bash-it-comp() COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) return 0 ;; - enable) - _bash-it-comp-enable-disable - return 0 - ;; - disable) - _bash-it-comp-enable-disable - return 0 + enable | disable) + if [ x"${chose_opt}" == x"enable" ];then + suffix="available-not-enabled" + else + suffix="enabled" + fi + case "${file_type}" in + alias) + _bash-it-comp-list-${suffix} aliases + return 0 + ;; + plugin) + _bash-it-comp-list-${suffix} plugins + return 0 + ;; + completion) + _bash-it-comp-list-${suffix} completion + return 0 + ;; + *) + _bash-it-comp-enable-disable + return 0 + ;; + esac ;; aliases) prevprev="${COMP_WORDS[COMP_CWORD-2]}" @@ -83,48 +100,6 @@ _bash-it-comp() ;; esac ;; - alias) - prevprev="${COMP_WORDS[COMP_CWORD-2]}" - - case "${prevprev}" in - enable) - _bash-it-comp-list-available-not-enabled aliases - return 0 - ;; - disable) - _bash-it-comp-list-enabled aliases - return 0 - ;; - esac - ;; - plugin) - prevprev="${COMP_WORDS[COMP_CWORD-2]}" - - case "${prevprev}" in - enable) - _bash-it-comp-list-available-not-enabled plugins - return 0 - ;; - disable) - _bash-it-comp-list-enabled plugins - return 0 - ;; - esac - ;; - completion) - prevprev="${COMP_WORDS[COMP_CWORD-2]}" - - case "${prevprev}" in - enable) - _bash-it-comp-list-available-not-enabled completion - return 0 - ;; - disable) - _bash-it-comp-list-enabled completion - return 0 - ;; - esac - ;; esac COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) diff --git a/lib/helpers.bash b/lib/helpers.bash index ebd68119..ae295a7c 100644 --- a/lib/helpers.bash +++ b/lib/helpers.bash @@ -37,8 +37,8 @@ bash-it () param '3: specific component [optional]' example '$ bash-it show plugins' example '$ bash-it help aliases' - example '$ bash-it enable plugin git' - example '$ bash-it disable alias hg' + example '$ bash-it enable plugin git [tmux]...' + example '$ bash-it disable alias hg [tmux]...' typeset verb=${1:-} shift typeset component=${1:-} @@ -72,7 +72,15 @@ bash-it () fi fi fi - $func $* + + if [ x"$verb" == x"enable" -o x"$verb" == x"disable" ];then + for arg in "$@" + do + $func $arg + done + else + $func $* + fi } _is_function () @@ -134,9 +142,9 @@ _bash-it-describe () printf "%-20s%-10s%s\n" "$(basename $f | cut -d'.' -f1)" " [$enabled]" "$(cat $f | metafor about-$file_type)" done printf '\n%s\n' "to enable $preposition $file_type, do:" - printf '%s\n' "$ bash-it enable $file_type <$file_type name> -or- $ bash-it enable $file_type all" + printf '%s\n' "$ bash-it enable $file_type <$file_type name> [$file_type name]... -or- $ bash-it enable $file_type all" printf '\n%s\n' "to disable $preposition $file_type, do:" - printf '%s\n' "$ bash-it disable $file_type <$file_type name> -or- $ bash-it disable $file_type all" + printf '%s\n' "$ bash-it disable $file_type <$file_type name> [$file_type name]... -or- $ bash-it disable $file_type all" } _disable-plugin () @@ -198,7 +206,7 @@ _disable-thing () else typeset plugin=$(command ls $BASH_IT/$subdirectory/enabled/$file_entity.*bash 2>/dev/null | head -1) if [ -z "$plugin" ]; then - printf '%s\n' "sorry, that does not appear to be an enabled $file_type." + printf '%s\n' "sorry, $file_entity does not appear to be an enabled $file_type." return fi rm $BASH_IT/$subdirectory/enabled/$(basename $plugin) @@ -267,7 +275,7 @@ _enable-thing () else typeset plugin=$(command ls $BASH_IT/$subdirectory/available/$file_entity.*bash 2>/dev/null | head -1) if [ -z "$plugin" ]; then - printf '%s\n' "sorry, that does not appear to be an available $file_type." + printf '%s\n' "sorry, $file_entity does not appear to be an available $file_type." return fi