From 2dbb1fa153c5e7626045a3301f89e92e5928b28a Mon Sep 17 00:00:00 2001 From: Tony Grosinger Date: Fri, 23 Sep 2022 16:12:41 -0700 Subject: [PATCH] Fixes to make bash prompt cleaner in more environments --- .bashrc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.bashrc b/.bashrc index 8228771..8f7f844 100755 --- a/.bashrc +++ b/.bashrc @@ -26,10 +26,7 @@ if [[ "${OSTYPE}" == "linux-gnu"* ]]; then # append and reload the history after each command PROMPT_COMMAND="history -a; history -n" - for filename in ${HOME}/.ssh/*.pub; do - keyname="$(basename ${filename} .pub)" - eval $(keychain --nogui --eval --quiet ${keyname}) - done + eval $(find "${HOME}/.ssh/" -type f -name "*.pub" | xargs -n 1 keychain --nogui --eval --quiet) # bind -x '"\C-r"':reset fi @@ -137,6 +134,11 @@ kubectl_context() { return 0 fi + kubectl cluster-info > /dev/null 2>&1 + if [ $? -ne 0 ]; then + return 0 + fi + context=$(kubectl config current-context 2>/dev/null) namespace=$(kubectl config view -o "jsonpath={.contexts[?(@.name==\"$context\")].context.namespace}") cluster=$(kubectl config view -o "jsonpath={.contexts[?(@.name==\"$context\")].context.cluster}")