-
-
Notifications
You must be signed in to change notification settings - Fork 79
Add kubecontext section to show currently active kubectl context #76
Conversation
ac6265e
to
fcd91ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey owais!
Thank you for your contribution! 😄
A few small comments here and there, but otherwise your PR looks good! 👍
Cheers!
# ------------------------------------------------------------------------------ | ||
function __sf_section_kubecontext -d "Display the kubernetes context" | ||
__sf_util_set_default SPACEFISH_KUBECONTEXT_SHOW true | ||
__sf_util_set_default SPACEFISH_KUBECONTEXT_PREFIX " " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the spaceship implementation, the default prefix is "at "
: https://github.com/denysdovhan/spaceship-prompt/blob/master/sections/kubecontext.zsh#L13
__sf_util_set_default SPACEFISH_KUBECONTEXT_SHOW true | ||
__sf_util_set_default SPACEFISH_KUBECONTEXT_PREFIX " " | ||
__sf_util_set_default SPACEFISH_KUBECONTEXT_SUFFIX $SPACEFISH_PROMPT_DEFAULT_SUFFIX | ||
__sf_util_set_default SPACEFISH_KUBECONTEXT_SYMBOL "☸️" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also appears the original implementation has a space following the ☸️ emoji. I would suggest adding it 😃
docs/Options.md
Outdated
| Variable | Default | Meaning | | ||
| :------- | :-----: | ------- | | ||
| `SPACEFISH_KUBECONTEXT_SHOW` | `true` | Show current kubectl context | | ||
| `SPACEFISH_KUBECONTEXT_PREFIX` | `$SPACEFISH_PROMPT_DEFAULT_PREFIX` | Prefix before the kubectl section | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest also changing the prefix here to at
.
docs/Options.md
Outdated
@@ -207,11 +207,24 @@ Go section is shown only in directories that contain `Godeps`, `glide.yaml`, any | |||
| Variable | Default | Meaning | | |||
| :------- | :-----: | ------- | | |||
| `SPACEFISH_GOLANG_SHOW` | `true` | Show current Go version or not | | |||
| `SPACEFISH_GOLANG_PREFIX` | `$SPACEFISH_PROMPT_DEFAULT_PREFIX` | Prefix before the Go section | | |||
| `SPACEFISH_GOLANG_PREFIX` | ` ` | Prefix before the Go section | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you might've unintentionally changed the value here.
The Go prompt prefix is correct to be $SPACEFISH_PROMPT_DEFAULT_PREFIX
.
return | ||
end | ||
|
||
set -l sf_kube_context (kubectl config current-context 2>/dev/null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To redirect to stderr in Fish, you would replace 2>
with ^
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this variable is local, I wouldn't use the sf_
prefix. That has only been used in the past for global variables so that we don't occupy the namespace.
__sf_lib_section \ | ||
$SPACEFISH_KUBECONTEXT_COLOR \ | ||
$SPACEFISH_KUBECONTEXT_PREFIX \ | ||
"$SPACEFISH_KUBECONTEXT_SYMBOL $sf_kube_context" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to add the space directly to the symbol (mentioned in the above comment), I would suggest then removing the space here.
docs/README.md
Outdated
@@ -17,6 +17,7 @@ | |||
* [Haskell (haskell)](./docs/Options.md#haskell-haskell) | |||
* [Pyenv (pyenv)](./docs/Options.md#pyenv-pyenv) | |||
* [Go (golang)](./docs/Options.md#go-golang) | |||
* [Kubectl (kubectl)](./docs/Options.md#kubectl) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like in the docs of spaceship, I would change the text here to Kubectl context (kubecontext)
. You will need to then change the anchor to #kubectl-context-kubecontext
. 🔗
docs/Options.md
Outdated
| `SPACEFISH_GOLANG_SUFFIX` | `$SPACEFISH_PROMPT_DEFAULT_SUFFIX` | Suffix after the Go section | | ||
| `SPACEFISH_GOLANG_SYMBOL` | `🐹·` | Character to be shown before Go version | | ||
| `SPACEFISH_GOLANG_COLOR` | `cyan` | Color of Go section | | ||
|
||
|
||
### Kubectl \(`kubectl`\) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like in the docs of spaceship, I would change the text here to Kubectl context (kubecontext)
😄
@matchai ^ |
docs/README.md
Outdated
@@ -17,6 +17,7 @@ | |||
* [Haskell (haskell)](./docs/Options.md#haskell-haskell) | |||
* [Pyenv (pyenv)](./docs/Options.md#pyenv-pyenv) | |||
* [Go (golang)](./docs/Options.md#go-golang) | |||
* [Kubectl (kubectl)](./docs/Options.md#kubectl-context-kubecontext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last nitpick:
I would change the text of the link to Kubectl context \(
kubecontext\)
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Looks good! Thanks again for your contribution! 😄 |
This broke with the latest Docker update I believe. Now that Docker bundles |
Hmm... It seems you may be right 🤔 |
Done. 😄 |
Issue: #73
Add kubecontext section
Description
Shows currently active kubectl context
Screenshots (if appropriate):
How Has This Been Tested?
Checklist: