From 7525f7e95756b32c67c480e62d373009e0a0cd00 Mon Sep 17 00:00:00 2001 From: Lee Date: Sat, 3 Aug 2024 21:25:58 +0800 Subject: [PATCH] update completion script --- Makefile | 2 -- scripts/completion/bash_autocomplete | 5 +---- scripts/completion/zsh_autocomplete | 16 +++++----------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 48042e980..5b93e5b30 100644 --- a/Makefile +++ b/Makefile @@ -108,9 +108,7 @@ dist-clean: install-completions: mkdir -p /usr/share/bash-completion/completions /usr/local/share/zsh/site-functions/ install -C ./scripts/completion/bash_autocomplete /usr/share/bash-completion/completions/curio - install -C ./scripts/completion/bash_autocomplete /usr/share/bash-completion/completions/sptool install -C ./scripts/completion/zsh_autocomplete /usr/local/share/zsh/site-functions/_curio - install -C ./scripts/completion/zsh_autocomplete /usr/local/share/zsh/site-functions/_sptool cu2k: GOFLAGS+=-tags=2k cu2k: curio diff --git a/scripts/completion/bash_autocomplete b/scripts/completion/bash_autocomplete index 7120a0d22..1e50939fc 100644 --- a/scripts/completion/bash_autocomplete +++ b/scripts/completion/bash_autocomplete @@ -1,7 +1,5 @@ #! /bin/bash -: ${PROG:=$(basename ${BASH_SOURCE})} - # Macs have bash3 for which the bash-completion package doesn't include # _init_completion. This is a minimal version of that function. _cli_init_completion() { @@ -31,5 +29,4 @@ _cli_bash_autocomplete() { fi } -complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG -unset PROG +complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete curio sptool diff --git a/scripts/completion/zsh_autocomplete b/scripts/completion/zsh_autocomplete index 943cf60b9..bc8802608 100644 --- a/scripts/completion/zsh_autocomplete +++ b/scripts/completion/zsh_autocomplete @@ -1,13 +1,7 @@ -#compdef program -compdef _program program +#compdef curio sptool +compdef _cli_zsh_autocomplete curio sptool -# Replace all occurrences of "program" in this file with the actual name of your -# CLI program. We recommend using Find+Replace feature of your editor. Let's say -# your CLI program is called "acme", then replace like so: -# * program => acme -# * _program => _acme - -_program() { +_cli_zsh_autocomplete() { local -a opts local cur cur=${words[-1]} @@ -25,6 +19,6 @@ _program() { } # don't run the completion function when being source-ed or eval-ed -if [ "$funcstack[1]" = "_program" ]; then - _program +if [ "$funcstack[1]" = "_cli_zsh_autocomplete" ]; then + _cli_zsh_autocomplete fi