From b31dec05705f3de48a691ea4c86f3586054b20ef Mon Sep 17 00:00:00 2001 From: "Gal@Shefet" Date: Tue, 23 Aug 2022 11:30:42 -0400 Subject: [PATCH] Added better kubectl and helm support for truenas --- .../bash.post/99_truenas.complete | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 _home/dot_sz.shrc.d/bash.post/99_truenas.complete diff --git a/_home/dot_sz.shrc.d/bash.post/99_truenas.complete b/_home/dot_sz.shrc.d/bash.post/99_truenas.complete new file mode 100644 index 0000000..ae90515 --- /dev/null +++ b/_home/dot_sz.shrc.d/bash.post/99_truenas.complete @@ -0,0 +1,21 @@ +if ( uname --kernel-release | grep -q truenas ); then + # Completion code is only avialable with `sudo`, the aliases below + # are desined for 'lazy-loading' the completion code, when it's time + # to enter the sudo password. + + if [[ -n "$(which-command 'k3s')" ]]; then + alias kubectl=' \ + ### Lazy load `kubectl` bash-completion \ + alias kubectl="sudo k3s kubectl "; \ + source <( kubectl completion bash ); \ + sudo k3s kubectl ' + fi + + if [[ -n "$(which-command 'helm')" ]]; then + alias helm=' \ + ### Lazy load `helm` bash-completion \ + alias helm="sudo KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm "; \ + source <( helm completion bash ); \ + sudo KUBECONFIG=/etc/rancher/k3s/k3s.yaml helm ' + fi +fi