refreshed dotfiles

This commit is contained in:
2025-01-05 12:01:29 +01:00
parent 86d224f266
commit 5849fbfe2d
12 changed files with 162 additions and 73 deletions

View File

@@ -43,5 +43,44 @@ case $_distro in
*) ICON="";;
esac
# Kubernetes integration
function update_kubernetes_context() {
if command -v kubectl &> /dev/null; then
KUBE_CTX=$(kubectl config current-context 2>/dev/null)
if [ $? -eq 0 ]; then
KUBE_NS=$(kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null)
export STARSHIP_KUBERNETES_CONTEXT="$KUBE_CTX"
[ -n "$KUBE_NS" ] && export STARSHIP_KUBERNETES_NAMESPACE="$KUBE_NS"
else
unset STARSHIP_KUBERNETES_CONTEXT
unset STARSHIP_KUBERNETES_NAMESPACE
fi
fi
}
# Update kubernetes context on startup
update_kubernetes_context
# Function to wrap kubectl and update context when needed
function kubectl() {
command kubectl "$@"
local exit_code=$?
# Update context if the command was successful and changed the context or namespace
if [ $exit_code -eq 0 ] && [[ "$1" == "config" && ("$2" == "use-context" || "$2" == "set-context") ]]; then
update_kubernetes_context
fi
return $exit_code
}
# Kubernetes aliases
alias k='kubectl'
alias kgp='kubectl get pods'
alias kgn='kubectl get nodes'
alias kgs='kubectl get services'
alias kgc='kubectl config get-contexts'
alias kuc='kubectl config use-context'
alias kns='kubectl config set-context --current --namespace'
export STARSHIP_DISTRO="$ICON"
export STARSHIP_DEVICE="$DEVICE"
export STARSHIP_DEVICE="$DEVICE"