completion/bash-it: `shfmt`
parent
dbb3ea4736
commit
d7695d5456
|
|
@ -37,6 +37,7 @@ aliases/available/vim.aliases.bash
|
||||||
#
|
#
|
||||||
completion/available/apm.completion.bash
|
completion/available/apm.completion.bash
|
||||||
completion/available/awless.completion.bash
|
completion/available/awless.completion.bash
|
||||||
|
completion/available/bash-it.completion.bash
|
||||||
completion/available/brew.completion.bash
|
completion/available/brew.completion.bash
|
||||||
completion/available/cargo.completion.bash
|
completion/available/cargo.completion.bash
|
||||||
completion/available/composer.completion.bash
|
completion/available/composer.completion.bash
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,79 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
_bash-it-comp-enable-disable()
|
_bash-it-comp-enable-disable() {
|
||||||
{
|
|
||||||
local enable_disable_args="alias completion plugin"
|
local enable_disable_args="alias completion plugin"
|
||||||
COMPREPLY=( $(compgen -W "${enable_disable_args}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${enable_disable_args}" -- "${cur}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-comp-list-available-not-enabled()
|
_bash-it-comp-list-available-not-enabled() {
|
||||||
{
|
|
||||||
local subdirectory="$1"
|
local subdirectory="$1"
|
||||||
|
|
||||||
local enabled_components all_things available_things
|
local enabled_components all_things available_things
|
||||||
|
|
||||||
all_things=( $(compgen -G "${BASH_IT}/$subdirectory/available/*.bash") ); all_things=( "${all_things[@]##*/}" )
|
all_things=($(compgen -G "${BASH_IT}/$subdirectory/available/*.bash"))
|
||||||
enabled_components=( $(command ls "${BASH_IT}"/{"$subdirectory"/,}enabled/*.bash 2>/dev/null) )
|
all_things=("${all_things[@]##*/}")
|
||||||
enabled_components=( "${enabled_components[@]##*/}" ); enabled_components="${enabled_components[@]##*---}"
|
enabled_components=($(command ls "${BASH_IT}"/{"$subdirectory"/,}enabled/*.bash 2> /dev/null))
|
||||||
available_things=( $(sort -d <(for i in ${enabled_components}
|
enabled_components=("${enabled_components[@]##*/}")
|
||||||
do
|
enabled_components="${enabled_components[@]##*---}"
|
||||||
all_things=( "${all_things[@]//$i}" )
|
available_things=($(sort -d <(
|
||||||
|
for i in ${enabled_components}; do
|
||||||
|
all_things=("${all_things[@]//$i/}")
|
||||||
done
|
done
|
||||||
printf '%s\n' "${all_things[@]}")) ); available_things="${available_things[@]%.*.bash}"
|
printf '%s\n' "${all_things[@]}"
|
||||||
|
)))
|
||||||
|
available_things="${available_things[@]%.*.bash}"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "all ${available_things}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "all ${available_things}" -- "${cur}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-comp-list-enabled()
|
_bash-it-comp-list-enabled() {
|
||||||
{
|
|
||||||
local subdirectory="$1"
|
local subdirectory="$1"
|
||||||
local suffix enabled_things
|
local suffix enabled_things
|
||||||
|
|
||||||
suffix="${subdirectory/plugins/plugin}"
|
suffix="${subdirectory/plugins/plugin}"
|
||||||
|
|
||||||
enabled_things=( $(sort -d <(compgen -G "${BASH_IT}/$subdirectory/enabled/*.${suffix}.bash") <(compgen -G "${BASH_IT}/enabled/*.${suffix}.bash")) )
|
enabled_things=($(sort -d <(compgen -G "${BASH_IT}/$subdirectory/enabled/*.${suffix}.bash") <(compgen -G "${BASH_IT}/enabled/*.${suffix}.bash")))
|
||||||
enabled_things=( "${enabled_things[@]##*/}" ); enabled_things=( "${enabled_things[@]##*---}" ); enabled_things="${enabled_things[@]%.*.bash}"
|
enabled_things=("${enabled_things[@]##*/}")
|
||||||
|
enabled_things=("${enabled_things[@]##*---}")
|
||||||
|
enabled_things="${enabled_things[@]%.*.bash}"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "all ${enabled_things}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "all ${enabled_things}" -- "${cur}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-comp-list-available()
|
_bash-it-comp-list-available() {
|
||||||
{
|
|
||||||
local subdirectory="$1"
|
local subdirectory="$1"
|
||||||
|
|
||||||
local enabled_things
|
local enabled_things
|
||||||
|
|
||||||
enabled_things=( $(sort -d <(compgen -G "${BASH_IT}/$subdirectory/available/*.bash")) )
|
enabled_things=($(sort -d <(compgen -G "${BASH_IT}/$subdirectory/available/*.bash")))
|
||||||
enabled_things=( "${enabled_things[@]##*/}" ); enabled_things="${enabled_things[@]%.*.bash}"
|
enabled_things=("${enabled_things[@]##*/}")
|
||||||
|
enabled_things="${enabled_things[@]%.*.bash}"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${enabled_things}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${enabled_things}" -- "${cur}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-comp-list-profiles()
|
_bash-it-comp-list-profiles() {
|
||||||
{
|
|
||||||
local profiles
|
local profiles
|
||||||
|
|
||||||
profiles=$(for f in `compgen -G "${BASH_IT}/profiles/*.bash_it" | sort -d`;
|
profiles=$(for f in $(compgen -G "${BASH_IT}/profiles/*.bash_it" | sort -d); do
|
||||||
do
|
|
||||||
basename $f | sed -e 's/.bash_it//g'
|
basename $f | sed -e 's/.bash_it//g'
|
||||||
done)
|
done)
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${profiles}" -- ${cur}) )
|
COMPREPLY=($(compgen -W "${profiles}" -- ${cur}))
|
||||||
}
|
}
|
||||||
|
|
||||||
_bash-it-comp()
|
_bash-it-comp() {
|
||||||
{
|
|
||||||
local cur prev opts
|
local cur prev opts
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD - 1]}"
|
||||||
chose_opt="${COMP_WORDS[1]}"
|
chose_opt="${COMP_WORDS[1]}"
|
||||||
file_type="${COMP_WORDS[2]}"
|
file_type="${COMP_WORDS[2]}"
|
||||||
opts="disable enable help migrate reload restart profile doctor search show update version"
|
opts="disable enable help migrate reload restart profile doctor search show update version"
|
||||||
case "${chose_opt}" in
|
case "${chose_opt}" in
|
||||||
show)
|
show)
|
||||||
local show_args="aliases completions plugins"
|
local show_args="aliases completions plugins"
|
||||||
COMPREPLY=( $(compgen -W "${show_args}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${show_args}" -- "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
help)
|
help)
|
||||||
|
|
@ -82,7 +82,7 @@ _bash-it-comp()
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
local help_args="aliases completions migrate plugins update"
|
local help_args="aliases completions migrate plugins update"
|
||||||
COMPREPLY=( $(compgen -W "${help_args}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${help_args}" -- "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
@ -108,30 +108,30 @@ _bash-it-comp()
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
local profile_args="load save list rm"
|
local profile_args="load save list rm"
|
||||||
COMPREPLY=( $(compgen -W "${profile_args}" -- ${cur}) )
|
COMPREPLY=($(compgen -W "${profile_args}" -- ${cur}))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
doctor)
|
doctor)
|
||||||
local doctor_args="errors warnings all"
|
local doctor_args="errors warnings all"
|
||||||
COMPREPLY=( $(compgen -W "${doctor_args}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${doctor_args}" -- "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
update)
|
update)
|
||||||
if [[ "${cur}" == -* ]];then
|
if [[ "${cur}" == -* ]]; then
|
||||||
local update_args="-s --silent"
|
local update_args="-s --silent"
|
||||||
else
|
else
|
||||||
local update_args="stable dev"
|
local update_args="stable dev"
|
||||||
fi
|
fi
|
||||||
COMPREPLY=( $(compgen -W "${update_args}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${update_args}" -- "${cur}"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
migrate | reload | restart | search | version)
|
migrate | reload | restart | search | version)
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
enable | disable)
|
enable | disable)
|
||||||
if [ x"${chose_opt}" == x"enable" ];then
|
if [ x"${chose_opt}" == x"enable" ]; then
|
||||||
suffix="available-not-enabled"
|
suffix="available-not-enabled"
|
||||||
else
|
else
|
||||||
suffix="enabled"
|
suffix="enabled"
|
||||||
|
|
@ -157,7 +157,7 @@ _bash-it-comp()
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue