Created
January 4, 2019 12:11
-
-
Save bageljp/02149dd2c8e3298b6c8f52f3697b91fe to your computer and use it in GitHub Desktop.
fish_prompt with k8s ctx and ns
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
$ diff ~/.config/fisherman/bobthefish/fish_prompt.fish ~/.config/fisherman/bobthefish/fish_prompt.fish.org Fri Jan 4 21:11:16 2019 | |
509,516c509 | |
< # Customize: START | |
< set -l ctx (string trim -c '"\' ' -- $val) | |
< set -l ns (kubectl config view -o "jsonpath={.contexts[?(@.name==\"$ctx\")].context.namespace}") | |
< [ -z $ns ]; and set -l ns 'default' | |
< set -l context "$ctx/$ns" | |
< # Customize: END | |
< | |
< #set -l context (string trim -c '"\' ' -- $val) | |
--- | |
> set -l context (string trim -c '"\' ' -- $val) |
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
$ diff ~/.config/fisherman/bobthefish/fish_right_prompt.fish ~/.config/fisherman/bobthefish/fish_right_prompt.fish.org Fri Jan 4 21:09:32 2019 | |
59,83d58 | |
< # Customize: START | |
< # refs: https://github.com/Ladicle/fish-kubectl-prompt | |
< function __kubectl_status | |
< [ -z "$KUBECTL_PROMPT_ICON" ]; and set -l KUBECTL_PROMPT_ICON "⎈" | |
< [ -z "$KUBECTL_PROMPT_SEPARATOR" ]; and set -l KUBECTL_PROMPT_SEPARATOR "/" | |
< set -l config $KUBECONFIG | |
< [ -z "$config" ]; and set -l config "$HOME/.kube/config" | |
< if [ ! -f $config ] | |
< echo (set_color red)$KUBECTL_PROMPT_ICON" "(set_color white)"no config" | |
< return | |
< end | |
< | |
< set -l ctx (kubectl config current-context 2>/dev/null) | |
< if [ $status -ne 0 ] | |
< echo (set_color red)$KUBECTL_PROMPT_ICON" "(set_color white)"no context" | |
< return | |
< end | |
< | |
< set -l ns (kubectl config view -o "jsonpath={.contexts[?(@.name==\"$context\")].context.namespace}") | |
< [ -z $ns ]; and set -l ns 'default' | |
< | |
< echo (set_color cyan)$KUBECTL_PROMPT_ICON" "(set_color white)"($ctx$KUBECTL_PROMPT_SEPARATOR$ns)" | |
< end | |
< # Customize: END | |
< | |
90d64 | |
< #__kubectl_status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/oh-my-fish/theme-bobthefish/