summaryrefslogtreecommitdiff
path: root/scripts/deploy/completions/fish.fish
diff options
context:
space:
mode:
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)'