summaryrefslogtreecommitdiff
path: root/scripts/deploy/completions/fish.fish
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/fish.fish
parent54b5567d6f1b1adaa6ada6a26faba0c5c492b7f3 (diff)
Add shell completions for new jvn CLI
Diffstat (limited to 'scripts/deploy/completions/fish.fish')
-rw-r--r--scripts/deploy/completions/fish.fish43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/deploy/completions/fish.fish b/scripts/deploy/completions/fish.fish
new file mode 100644
index 0000000..2904495
--- /dev/null
+++ b/scripts/deploy/completions/fish.fish
@@ -0,0 +1,43 @@
+#!/usr/bin/env fish
+function __jvn_fish_complete
+ set -l cmdline (commandline -opc)
+ set -l buffer (commandline -b)
+ set -l cursor (commandline -C)
+
+ set -l current_word ""
+ set -l previous_word ""
+ set -l word_index 0
+ set -l char_count 0
+
+ for i in (seq (count $cmdline))
+ set word $cmdline[$i]
+ set char_count (math $char_count + (string length "$word") + 1)
+
+ if test $cursor -le $char_count
+ set word_index $i
+ set current_word $word
+ if test $i -gt 1
+ set previous_word $cmdline[(math $i - 1)]
+ end
+ break
+ end
+ end
+
+ set -l args \
+ -f "$buffer" \
+ -C "$cursor" \
+ -w "$current_word" \
+ -p "$previous_word" \
+ -c "$cmdline[1]" \
+ -i "$word_index" \
+ -a $cmdline
+
+ set -l output (jvn_comp $args 2>/dev/null)
+ if test "$output" = "_file_"
+ __fish_complete_path "$current_word"
+ else
+ printf "%s\n" $output
+ end
+end
+
+complete -c jvn -a '(__jvn_fish_complete)'