add kubectl scripts

This commit is contained in:
Sean Buckley 2023-04-30 02:11:27 -04:00
parent 2759fbeaa6
commit b1231fb0b8
2 changed files with 25 additions and 3 deletions

View file

@ -1,6 +1,9 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
{ {
imports = [ ./powerline.nix ]; imports = [
./kubectl.nix
./powerline.nix
];
sconfig.powerline.enable = lib.mkDefault true; sconfig.powerline.enable = lib.mkDefault true;
@ -15,8 +18,6 @@
inetutils inetutils
iotop iotop
jq jq
kubectl
kubernetes-helm
lm_sensors lm_sensors
ncdu ncdu
nix-index nix-index

21
modules/cli/kubectl.nix Normal file
View file

@ -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
];
}