diff --git a/share/completions/mmdc.fish b/share/completions/mmdc.fish index d94857514..68414fd23 100644 --- a/share/completions/mmdc.fish +++ b/share/completions/mmdc.fish @@ -19,7 +19,7 @@ complete -c $command -s h -l height -x \ complete -c $command -s i -l input -r -d 'Specify the input file of a chart' complete -c $command -s o -l output -r \ - -a '(__fish_print_extensions svg md png pdf)' \ + -a '(__fish_complete_extensions svg\tdefault md png pdf)' \ -d 'Specify the output file of a chart' complete -c $command -s e -l outputFormat -x \ diff --git a/share/functions/__fish_complete_extensions.fish b/share/functions/__fish_complete_extensions.fish new file mode 100644 index 000000000..f39adb6ff --- /dev/null +++ b/share/functions/__fish_complete_extensions.fish @@ -0,0 +1,16 @@ +function __fish_complete_extensions \ + --description 'Suggest provided extensions as $argv if the current token ends with a dot' + + set token (commandline -c -t) + + switch "$token" + case '*.' + for extension in $argv + if string match --quiet --regex '\\\t|\t' -- $extension + echo -e "$token$extension" + else + printf "%s%s\n" $token $extension + end + end + end +end diff --git a/share/functions/__fish_print_extensions.fish b/share/functions/__fish_print_extensions.fish deleted file mode 100644 index 2c1c20acc..000000000 --- a/share/functions/__fish_print_extensions.fish +++ /dev/null @@ -1,12 +0,0 @@ -function __fish_print_extensions \ - --description 'Suggest provided extensions as $argv if the current token ends with a dot' - - set token (commandline -c -t) - - switch "$token" - case '*.' - for extension in $argv - printf "%s%s\n" $token $extension - end - end -end