Added support for `bash-it help completions` command.

It's showing the same output as `bash-it show completions`,
to keep things simple.
pull/430/head
Nils Winkler 2015-03-23 07:37:50 +01:00
parent e800a684f9
commit d29d6df2f2
2 changed files with 37 additions and 29 deletions

View File

@ -9,40 +9,40 @@ _bash-it-comp-enable-disable()
_bash-it-comp-list-available-not-enabled() _bash-it-comp-list-available-not-enabled()
{ {
subdirectory="$1" subdirectory="$1"
local available_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`; local available_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`;
do do
if [ ! -e $BASH_IT/$subdirectory/enabled/$(basename $f) ] if [ ! -e $BASH_IT/$subdirectory/enabled/$(basename $f) ]
then then
basename $f | cut -d'.' -f1 basename $f | cut -d'.' -f1
fi fi
done) done)
COMPREPLY=( $(compgen -W "all ${available_things}" -- ${cur}) ) COMPREPLY=( $(compgen -W "all ${available_things}" -- ${cur}) )
} }
_bash-it-comp-list-enabled() _bash-it-comp-list-enabled()
{ {
subdirectory="$1" subdirectory="$1"
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/enabled/*.bash`; local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/enabled/*.bash`;
do do
basename $f | cut -d'.' -f1 basename $f | cut -d'.' -f1
done) done)
COMPREPLY=( $(compgen -W "all ${enabled_things}" -- ${cur}) ) COMPREPLY=( $(compgen -W "all ${enabled_things}" -- ${cur}) )
} }
_bash-it-comp-list-available() _bash-it-comp-list-available()
{ {
subdirectory="$1" subdirectory="$1"
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`; local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`;
do do
basename $f | cut -d'.' -f1 basename $f | cut -d'.' -f1
done) done)
COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) )
} }
_bash-it-comp() _bash-it-comp()
@ -51,9 +51,9 @@ _bash-it-comp()
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="help show enable disable" opts="help show enable disable"
case "${prev}" in case "${prev}" in
show) show)
local show_args="plugins aliases completions" local show_args="plugins aliases completions"
@ -61,7 +61,7 @@ _bash-it-comp()
return 0 return 0
;; ;;
help) help)
local help_args="plugins aliases" local help_args="plugins aliases completions"
COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) )
return 0 return 0
;; ;;
@ -75,17 +75,17 @@ _bash-it-comp()
;; ;;
aliases) aliases)
prevprev="${COMP_WORDS[COMP_CWORD-2]}" prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in case "${prevprev}" in
help) help)
_bash-it-comp-list-available aliases _bash-it-comp-list-available aliases
return 0 return 0
;; ;;
esac esac
;; ;;
alias) alias)
prevprev="${COMP_WORDS[COMP_CWORD-2]}" prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in case "${prevprev}" in
enable) enable)
_bash-it-comp-list-available-not-enabled aliases _bash-it-comp-list-available-not-enabled aliases
@ -96,10 +96,10 @@ _bash-it-comp()
return 0 return 0
;; ;;
esac esac
;; ;;
plugin) plugin)
prevprev="${COMP_WORDS[COMP_CWORD-2]}" prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in case "${prevprev}" in
enable) enable)
_bash-it-comp-list-available-not-enabled plugins _bash-it-comp-list-available-not-enabled plugins
@ -110,10 +110,10 @@ _bash-it-comp()
return 0 return 0
;; ;;
esac esac
;; ;;
completion) completion)
prevprev="${COMP_WORDS[COMP_CWORD-2]}" prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in case "${prevprev}" in
enable) enable)
_bash-it-comp-list-available-not-enabled completion _bash-it-comp-list-available-not-enabled completion
@ -124,11 +124,11 @@ _bash-it-comp()
return 0 return 0
;; ;;
esac esac
;; ;;
esac esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0
} }

View File

@ -115,7 +115,7 @@ _bash-it-describe ()
_param '3: file_type' _param '3: file_type'
_param '4: column_header' _param '4: column_header'
_example '$ _bash-it-describe "plugins" "a" "plugin" "Plugin"' _example '$ _bash-it-describe "plugins" "a" "plugin" "Plugin"'
subdirectory="$1" subdirectory="$1"
preposition="$2" preposition="$2"
file_type="$3" file_type="$3"
@ -176,7 +176,7 @@ _disable-thing ()
_param '2: file_type' _param '2: file_type'
_param '3: file_entity' _param '3: file_entity'
_example '$ _disable-thing "plugins" "plugin" "ssh"' _example '$ _disable-thing "plugins" "plugin" "ssh"'
subdirectory="$1" subdirectory="$1"
file_type="$2" file_type="$2"
file_entity="$3" file_entity="$3"
@ -244,8 +244,8 @@ _enable-thing ()
_param '1: subdirectory' _param '1: subdirectory'
_param '2: file_type' _param '2: file_type'
_param '3: file_entity' _param '3: file_entity'
_example '$ _enable-thing "plugins" "plugin" "ssh"' _example '$ _enable-thing "plugins" "plugin" "ssh"'
subdirectory="$1" subdirectory="$1"
file_type="$2" file_type="$2"
file_entity="$3" file_entity="$3"
@ -285,6 +285,14 @@ _enable-thing ()
printf '%s\n' "$file_entity enabled." printf '%s\n' "$file_entity enabled."
} }
_help-completions()
{
_about 'summarize all completions available in bash-it'
_group 'lib'
_bash-it-completions
}
_help-aliases() _help-aliases()
{ {
_about 'shows help for all aliases, or a specific alias group' _about 'shows help for all aliases, or a specific alias group'