From 413fd2fc03c13915ed0b567366a53127554f7d5c Mon Sep 17 00:00:00 2001 From: Kevin Konrad Date: Wed, 28 Jul 2021 17:59:42 +0200 Subject: [PATCH] extract argcomplete completion mechanism into its own function --- share/completions/az.fish | 13 +------------ share/completions/qmk.fish | 13 +------------ share/functions/__fish_argcomplete_complete.fish | 10 ++++++++++ 3 files changed, 12 insertions(+), 24 deletions(-) create mode 100644 share/functions/__fish_argcomplete_complete.fish diff --git a/share/completions/az.fish b/share/completions/az.fish index 0601acb34..3f87c1778 100644 --- a/share/completions/az.fish +++ b/share/completions/az.fish @@ -1,12 +1 @@ -function __fish_az_complete - set -lx _ARGCOMPLETE 1 - set -lx _ARGCOMPLETE_IFS \n - set -lx _ARGCOMPLETE_SUPPRESS_SPACE 1 - set -lx _ARGCOMPLETE_SHELL fish - set -lx COMP_LINE (commandline -pc) - set -lx COMP_POINT (string length (commandline -cp)) - set -lx COMP_TYPE - az 8>&1 9>&2 2>/dev/null -end - -complete -c az -f -a '(__fish_az_complete)' +complete -c az -f -a '(__fish_argcomplete_complete az)' diff --git a/share/completions/qmk.fish b/share/completions/qmk.fish index 57b046631..7c22c279b 100644 --- a/share/completions/qmk.fish +++ b/share/completions/qmk.fish @@ -1,12 +1 @@ -function __fish_qmk_complete - set -lx _ARGCOMPLETE 1 - set -lx _ARGCOMPLETE_IFS \n - set -lx _ARGCOMPLETE_SUPPRESS_SPACE 1 - set -lx _ARGCOMPLETE_SHELL fish - set -lx COMP_LINE (commandline -pc) - set -lx COMP_POINT (string length (commandline -cp)) - set -lx COMP_TYPE - qmk 8>&1 9>&2 2>/dev/null -end - -complete -c qmk -f -a '(__fish_qmk_complete)' +complete -c qmk -f -a '(__fish_argcomplete_complete qmk)' diff --git a/share/functions/__fish_argcomplete_complete.fish b/share/functions/__fish_argcomplete_complete.fish new file mode 100644 index 000000000..8d4cdf6bf --- /dev/null +++ b/share/functions/__fish_argcomplete_complete.fish @@ -0,0 +1,10 @@ +function __fish_argcomplete_complete + set -lx _ARGCOMPLETE 1 + set -lx _ARGCOMPLETE_IFS \n + set -lx _ARGCOMPLETE_SUPPRESS_SPACE 1 + set -lx _ARGCOMPLETE_SHELL fish + set -lx COMP_LINE (commandline -pc) + set -lx COMP_POINT (string length (commandline -cp)) + set -lx COMP_TYPE + $argv 8>&1 9>&2 2>/dev/null +end