mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-01 06:39:17 +00:00
add Shell Completion section to README add pdm script completion add pre-commit config
29 lines
689 B
Bash
29 lines
689 B
Bash
_slobs_cli_completion() {
|
|
local IFS=$'\n'
|
|
local response
|
|
|
|
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _SLOBS_CLI_COMPLETE=bash_complete $1)
|
|
|
|
for completion in $response; do
|
|
IFS=',' read type value <<< "$completion"
|
|
|
|
if [[ $type == 'dir' ]]; then
|
|
COMPREPLY=()
|
|
compopt -o dirnames
|
|
elif [[ $type == 'file' ]]; then
|
|
COMPREPLY=()
|
|
compopt -o default
|
|
elif [[ $type == 'plain' ]]; then
|
|
COMPREPLY+=($value)
|
|
fi
|
|
done
|
|
|
|
return 0
|
|
}
|
|
|
|
_slobs_cli_completion_setup() {
|
|
complete -o nosort -F _slobs_cli_completion slobs-cli
|
|
}
|
|
|
|
_slobs_cli_completion_setup;
|