From 6bd9a52adb23359da5912225dda0e3a490bd47bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=9F=E9=85=8C=20=E9=B5=AC=E5=85=84?= Date: Wed, 10 Aug 2022 14:03:51 +0800 Subject: [PATCH] Added kres & kconf --- bash/bashrc/sources/10_aliases | 3 +++ bash/bashrc/sources/12_shortcuts | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/bash/bashrc/sources/10_aliases b/bash/bashrc/sources/10_aliases index 3879791..cb5b644 100755 --- a/bash/bashrc/sources/10_aliases +++ b/bash/bashrc/sources/10_aliases @@ -38,3 +38,6 @@ alias ssh-add="ssh-add -t 43200" # Pretty print sqlite3 alias sqlite3="sqlite3 -header -column" + +# Kubernetes +alias kconf='kubectl config' diff --git a/bash/bashrc/sources/12_shortcuts b/bash/bashrc/sources/12_shortcuts index 0767d74..a1f74a3 100755 --- a/bash/bashrc/sources/12_shortcuts +++ b/bash/bashrc/sources/12_shortcuts @@ -14,3 +14,14 @@ function git-config-as { echo "Configured as \"$NAME <$EMAIL>\"" } +# Kubernetes +function kres { + local _O _D + _O="-ocustom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name" + _D="[0-9A-Za-z\-]" + if [ -z "$3" ]; then + kubectl get $1 -A $_O | grep "$2" + else + kubectl get $1 -A $_O | grep "$_D*$2$_D*\s\+$_D*$3$_D*" + fi +}