forked from urfave/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfish_autocomplete
More file actions
35 lines (30 loc) · 1.03 KB
/
fish_autocomplete
File metadata and controls
35 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This is a shell completion script auto-generated by https://github.com/urfave/cli for fish.
function __%[1]_perform_completion
# Extract all args except the last one
set -l args (commandline -opc)
# Extract the last arg (partial input)
set -l lastArg (commandline -ct)
set -l results ($args[1] $args[2..-1] $lastArg --generate-shell-completion 2> /dev/null)
# Remove trailing empty lines
for line in $results[-1..1]
if test (string trim -- $line) = ""
set results $results[1..-2]
else
break
end
end
for line in $results
if not string match -q -- "%[1]*" $line
set -l parts (string split -m 1 ":" -- "$line")
if test (count $parts) -eq 2
printf "%s\t%s\n" "$parts[1]" "$parts[2]"
else
printf "%s\n" "$line"
end
end
end
end
# Clear existing completions for %[1]
complete -c %[1] -e
# Register completion function
complete -c %[1] -f -a '(__%[1]_perform_completion)'