feat: add --generate-completion for shell tab completion
- Add clap_complete dependency for bash/zsh/fish/elvish/powershell - Add --generate-completion <shell> flag that prints completion script to stdout - profile.bash sources completions via command keep --generate-completion bash - @ and @@ aliases get completions via wrapper functions that delegate to _keep - README updated with Shell Completion section
This commit is contained in:
18
profile.bash
18
profile.bash
@@ -40,4 +40,22 @@ function @@ {
|
||||
keep --get "$@"
|
||||
}
|
||||
|
||||
# Shell completions
|
||||
. <(command keep --generate-completion bash)
|
||||
|
||||
___keep_save_completion() {
|
||||
COMP_WORDS=(keep --save "${COMP_WORDS[@]:1}")
|
||||
COMP_CWORD=$((COMP_CWORD + 1))
|
||||
_keep
|
||||
}
|
||||
|
||||
___keep_get_completion() {
|
||||
COMP_WORDS=(keep --get "${COMP_WORDS[@]:1}")
|
||||
COMP_CWORD=$((COMP_CWORD + 1))
|
||||
_keep
|
||||
}
|
||||
|
||||
complete -F ___keep_save_completion @
|
||||
complete -F ___keep_get_completion @@
|
||||
|
||||
__keep_preexec_init
|
||||
|
||||
Reference in New Issue
Block a user