From 72f80ea51f25256d0c463c2f3dc3d8670cfc4634 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sat, 14 Mar 2026 22:12:30 +0800 Subject: Add shell completions for new jvn CLI --- scripts/deploy/completions/fish.fish | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 scripts/deploy/completions/fish.fish (limited to 'scripts/deploy/completions/fish.fish') 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)' -- cgit