completion: Add bash-it profile subcommand

pull/1865/head
Noah Gorny 2021-02-13 17:18:17 +02:00
parent 41cba9d7e4
commit eaa2f829bd
1 changed files with 31 additions and 1 deletions

View File

@ -57,6 +57,18 @@ _bash-it-comp-list-available()
COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${enabled_things}" -- ${cur}) )
} }
_bash-it-comp-list-profiles()
{
local profiles
profiles=$(for f in `compgen -G "${BASH_IT}/profiles/*.bash_it" | sort -d`;
do
basename $f | sed -e 's/.bash_it//g'
done)
COMPREPLY=( $(compgen -W "${profiles}" -- ${cur}) )
}
_bash-it-comp() _bash-it-comp()
{ {
local cur prev opts local cur prev opts
@ -65,7 +77,7 @@ _bash-it-comp()
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 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"
@ -82,6 +94,24 @@ _bash-it-comp()
return 0 return 0
fi fi
;; ;;
profile)
case "${file_type}" in
load)
if [[ "load" == "$prev" ]]; then
_bash-it-comp-list-profiles
fi
return 0
;;
save)
return 0
;;
*)
local profile_args="load save"
COMPREPLY=( $(compgen -W "${profile_args}" -- ${cur}) )
return 0
;;
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}) )