From 8241576f28fcfd8a0732b598a806ff246724d222 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Mon, 2 Nov 2020 02:45:40 -0300 Subject: [PATCH] fix: improve kubectx completion on fish (#269) --- completion/kubectx.fish | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/completion/kubectx.fish b/completion/kubectx.fish index eacaac6..61da12c 100644 --- a/completion/kubectx.fish +++ b/completion/kubectx.fish @@ -1,3 +1,10 @@ # kubectx -complete -f -c kubectx -a "- (kubectl config get-contexts --output='name')" +function __fish_kubectx_arg_number -a number + set -l cmd (commandline -opc) + test (count $cmd) -eq $number +end + +complete -f -c kubectx +complete -f -x -c kubectx -n '__fish_kubectx_arg_number 1' -a "(kubectl config get-contexts --output='name')" +complete -f -x -c kubectx -n '__fish_kubectx_arg_number 1' -a "-" -d "switch to the previous namespace in this context"