Last active
September 8, 2018 22:10
-
-
Save philicious/3bb137ee370b6942579a366469345f72 to your computer and use it in GitHub Desktop.
kubernetes info plugin for zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.oh-my-zsh/custom/plugins/kate/kate.plugin.zsh | |
function gcloudAccount { | |
#echo `gcloud config configurations list --filter is_active=true --format='value(name)'|head -n1` 2>/dev/null | |
# faster one | |
cat ~/.config/gcloud/active_config | |
} | |
function k8sContext { | |
echo `kubectl config current-context |cut -c 1-15` 2>/dev/null | |
} | |
function k8sNamespace { | |
ns="$(kubectl config view --minify --output 'jsonpath={..namespace}')" | |
ns="${ns:-default}" | |
echo "${ns}" | |
} | |
#### and in .zshrc after activating the plugin | |
GCLOUD_PROMPT='%{$fg_bold[blue]%}gcloud:(%{$fg[red]%}$(gcloudAccount)%{$fg_bold[blue]%})%{$reset_color%}' | |
K8S_CTX_PROMPT='%{$fg_bold[blue]%}k8s-ctx:(%{$fg[red]%}$(k8sContext)%{$fg_bold[blue]%})%{$reset_color%}' | |
K8S_NS_PROMPT='%{$fg_bold[blue]%}k8s-ns:(%{$fg[red]%}$(k8sNamespace)%{$fg_bold[blue]%})%{$reset_color%}' | |
RPROMPT="$GCLOUD_PROMPT $K8S_CTX_PROMPT $K8S_NS_PROMPT" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment