summaryrefslogtreecommitdiff
path: root/scripts/deploy/completions/zsh.sh
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-14 22:12:30 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-14 22:40:12 +0800
commit72f80ea51f25256d0c463c2f3dc3d8670cfc4634 (patch)
treeb200a3ab1a4c718034458863570a064b52bafdcd /scripts/deploy/completions/zsh.sh
parent54b5567d6f1b1adaa6ada6a26faba0c5c492b7f3 (diff)
Add shell completions for new jvn CLI
Diffstat (limited to 'scripts/deploy/completions/zsh.sh')
-rw-r--r--scripts/deploy/completions/zsh.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/scripts/deploy/completions/zsh.sh b/scripts/deploy/completions/zsh.sh
new file mode 100644
index 0000000..2b2a96b
--- /dev/null
+++ b/scripts/deploy/completions/zsh.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env zsh
+_jvn_completion() {
+ local -a args
+ local suggestions
+
+ local buffer="$BUFFER"
+ local cursor="$CURSOR"
+ local current_word="${words[$CURRENT]}"
+ local previous_word=""
+ local command_name="${words[1]}"
+ local word_index="$CURRENT"
+
+ if [[ $CURRENT -gt 1 ]]; then
+ previous_word="${words[$((CURRENT-1))]}"
+ fi
+
+ args=(
+ -f "$buffer"
+ -C "$cursor"
+ -w "$current_word"
+ -p "$previous_word"
+ -c "$command_name"
+ -i "$word_index"
+ -a "${words[@]}"
+ )
+
+ suggestions=$(jvn_comp "${args[@]}" 2>/dev/null)
+
+ if [[ $? -eq 0 ]] && [[ -n "$suggestions" ]]; then
+ local -a completions
+ completions=(${(f)suggestions})
+
+ if [[ "${completions[1]}" == "_file_" ]]; then
+ shift completions
+ _files
+ elif (( $+functions[_describe] )); then
+ _describe 'jvn commands' completions
+ else
+ compadd -a completions
+ fi
+ fi
+}
+
+compdef _jvn_completion jvn
+
+if [[ $? -ne 0 ]]; then
+ compctl -K _jvn_completion jvn
+fi