From 84a8aa1ed575f02b66f1d45f71197e76492a2e85 Mon Sep 17 00:00:00 2001 From: Jonas Forsberg Date: Fri, 8 Jul 2022 09:32:49 +0200 Subject: [PATCH] better command check for kubectl --- .functions/ps1.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.functions/ps1.sh b/.functions/ps1.sh index f45c8cf..313b34a 100644 --- a/.functions/ps1.sh +++ b/.functions/ps1.sh @@ -48,7 +48,7 @@ function bash_ps1 () { fi fi [[ -n "$VIRTUAL_ENV" ]] && PYTHON_ENV="${PS1_COLOR_DIVIDER}─[${PS1_COLOR_VENV}${VIRTUAL_ENV##*/}${PS1_COLOR_DIVIDER}]" - if [[ $(type kubectl) ]]; then + if command -v kubectl > /dev/null; then CURRENT_CONTEXT="$(kubectl config current-context 2>/dev/null)" if [[ "$CURRENT_CONTEXT" != "default" ]];then K8S_CURRENT_CONTEXT="${PS1_COLOR_DIVIDER}[${PS1_COLOR_KUBERNETES}${CURRENT_CONTEXT}${PS1_COLOR_DIVIDER}]"