From b1231fb0b8628cdcf4c313b57eb0a1d872fb45bb Mon Sep 17 00:00:00 2001 From: Sean Buckley Date: Sun, 30 Apr 2023 02:11:27 -0400 Subject: [PATCH] add kubectl scripts --- modules/cli/default.nix | 7 ++++--- modules/cli/kubectl.nix | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 modules/cli/kubectl.nix diff --git a/modules/cli/default.nix b/modules/cli/default.nix index 646223b..baf7ce0 100644 --- a/modules/cli/default.nix +++ b/modules/cli/default.nix @@ -1,6 +1,9 @@ { config, pkgs, lib, ... }: { - imports = [ ./powerline.nix ]; + imports = [ + ./kubectl.nix + ./powerline.nix + ]; sconfig.powerline.enable = lib.mkDefault true; @@ -15,8 +18,6 @@ inetutils iotop jq - kubectl - kubernetes-helm lm_sensors ncdu nix-index diff --git a/modules/cli/kubectl.nix b/modules/cli/kubectl.nix new file mode 100644 index 0000000..1d8cc38 --- /dev/null +++ b/modules/cli/kubectl.nix @@ -0,0 +1,21 @@ +{ config, pkgs, lib, ... }: +{ + programs.bash.interactiveShellInit = '' + kc(){ + export KUBECONFIG=~/.kube/config."$1" + kubectl get nodes + } + _kc_completion(){ + [ "''${#COMP_WORDS[@]}" != "2" ] || + COMPREPLY=($(compgen -W "$(ls ~/.kube/ | grep '^config\.' | sed 's/^config\.//g')" -- "''${COMP_WORDS[1]}")) + } + complete -F _kc_completion kc + source <(kubectl completion bash) + complete -F __start_kubectl k + alias k=kubectl + ''; + environment.systemPackages = [ + pkgs.kubectl + pkgs.kubernetes-helm + ]; +}