From 958131271a6f82f1d6cf22cdbb6ad6742d34d4c8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Wed, 19 Dec 2018 11:47:21 +0100 Subject: zsh: Add kube context to prompt --- zsh/.config/zsh/.zshrc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index 5265d1f..6effdeb 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -207,6 +207,22 @@ then else AGKOZAK_PROMPT_DIRTRIM=0 + check_kubectl_context () { + if [[ "$PWD" =~ /kubernetes ]] + then + kubectl_context=$(kubectl config current-context) + if [[ $kubectl_context =~ production ]] + then + prompt_context="%F{red}[${kubectl_context}]%f" + else + prompt_context="%F{yellow}[${kubectl_context}]%f" + fi + else + prompt_context= + fi + } + precmd_functions+=(check_kubectl_context) + AGKOZAK_CUSTOM_RPROMPT='${prompt_context}%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}%3v%f.)' fi if [[ -n $commands[fzf] ]] -- cgit 1.4.1