diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-26 15:55:10 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-26 15:55:10 +0800 |
| commit | fb2ffa849a2cf9251cc274ebea5daa9898579787 (patch) | |
| tree | 53b87ee60ba7c6ee7b001221855a6f3bff7e8526 /scripts/deploy/completions/zsh.zsh | |
| parent | 4cb7c2e91d7dbde32de31e6ab48683d60212ec1d (diff) | |
Add shell completion system with descriptions and i18n support
Diffstat (limited to 'scripts/deploy/completions/zsh.zsh')
| -rw-r--r-- | scripts/deploy/completions/zsh.zsh | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/scripts/deploy/completions/zsh.zsh b/scripts/deploy/completions/zsh.zsh index 2b9e7f9..99ecd09 100644 --- a/scripts/deploy/completions/zsh.zsh +++ b/scripts/deploy/completions/zsh.zsh @@ -34,10 +34,29 @@ _jvn_completion() { if [[ "${completions[1]}" == "_file_" ]]; then shift completions _files - elif (( $+functions[_describe] )); then - _describe 'jvn commands' completions else - compadd -a completions + local -a parsed_completions + for item in "${completions[@]}"; do + if [[ "$item" =~ '^([^$]+)\$\((.+)\)$' ]]; then + parsed_completions+=("${match[1]}:${match[2]}") + else + parsed_completions+=("$item") + fi + done + + if (( $+functions[_describe] )); then + _describe 'jvn commands' parsed_completions + else + local -a simple_completions + for item in "${parsed_completions[@]}"; do + if [[ "$item" =~ '^([^:]+):(.+)$' ]]; then + simple_completions+=("${match[1]}") + else + simple_completions+=("$item") + fi + done + compadd -a simple_completions + fi fi fi } |
