mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-18 06:53:39 +00:00
add shell completion scripts
add Shell Completion section to README add pdm script completion add pre-commit config
This commit is contained in:
28
completions/_slobs-cli.bash
Normal file
28
completions/_slobs-cli.bash
Normal file
@@ -0,0 +1,28 @@
|
||||
_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;
|
||||
Reference in New Issue
Block a user