Fix abook completions

This commit is contained in:
Jason Nader 2020-03-21 15:56:35 +09:00 committed by Fabian Homborg
parent 401e5d1f6b
commit eba099bf77

View File

@ -1,15 +1,27 @@
function __fish_complete_abook_formats --description 'Complete abook formats' function __fish_complete_abook_formats --description 'Complete abook formats'
set -l pat abook --formats | while read -l x
switch $x
case "input formats:"
set format input
case "output formats:"
set format output
case "query-compatible output formats:"
set format ignore
end
set --append "$format" (string replace -rf '\t(.*\t.*)' '$1' -- $x)
end
switch $argv[1] switch $argv[1]
case in case in
set pat '/output:/,$d; /input:\|^$/d' for l in $input
echo $l
end
case out case out
set pat '/input:/,/output:/d; /^$/d' for l in $output
echo $l
end
case '*' case '*'
return 1 return 1
end end
abook --formats | sed -e $pat -e 's/^\s\+//'
end end
complete -c abook -s h -d 'Show usage' complete -c abook -s h -d 'Show usage'