Merge pull request #430 from nwinkler/completion-help

Added support for `bash-it help completions` command.
pull/431/head
Nils Winkler 2015-03-23 08:20:41 +01:00
commit cbba9c16ef
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()
{
subdirectory="$1"
local available_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`;
do
local available_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`;
do
if [ ! -e $BASH_IT/$subdirectory/enabled/$(basename $f) ]
then
basename $f | cut -d'.' -f1
fi
done)
COMPREPLY=( $(compgen -W "all ${available_things}" -- ${cur}) )
COMPREPLY=( $(compgen -W "all ${available_things}" -- ${cur}) )
}
_bash-it-comp-list-enabled()
{
subdirectory="$1"
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/enabled/*.bash`;
do
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/enabled/*.bash`;
do
basename $f | cut -d'.' -f1
done)
COMPREPLY=( $(compgen -W "all ${enabled_things}" -- ${cur}) )
COMPREPLY=( $(compgen -W "all ${enabled_things}" -- ${cur}) )
}
_bash-it-comp-list-available()
{
subdirectory="$1"
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`;
do
local enabled_things=$(for f in `ls -1 $BASH_IT/$subdirectory/available/*.bash`;
do
basename $f | cut -d'.' -f1
done)
COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) )
COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) )
}
_bash-it-comp()
@ -51,9 +51,9 @@ _bash-it-comp()
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="help show enable disable"
case "${prev}" in
show)
local show_args="plugins aliases completions"
@ -61,7 +61,7 @@ _bash-it-comp()
return 0
;;
help)
local help_args="plugins aliases"
local help_args="plugins aliases completions"
COMPREPLY=( $(compgen -W "${help_args}" -- ${cur}) )
return 0
;;
@ -75,17 +75,17 @@ _bash-it-comp()
;;
aliases)
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in
help)
_bash-it-comp-list-available aliases
return 0
;;
esac
;;
;;
alias)
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in
enable)
_bash-it-comp-list-available-not-enabled aliases
@ -96,10 +96,10 @@ _bash-it-comp()
return 0
;;
esac
;;
;;
plugin)
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in
enable)
_bash-it-comp-list-available-not-enabled plugins
@ -110,10 +110,10 @@ _bash-it-comp()
return 0
;;
esac
;;
;;
completion)
prevprev="${COMP_WORDS[COMP_CWORD-2]}"
case "${prevprev}" in
enable)
_bash-it-comp-list-available-not-enabled completion
@ -124,11 +124,11 @@ _bash-it-comp()
return 0
;;
esac
;;
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}

View File

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