diff --git a/docs/Options.md b/docs/Options.md index 470dbc3..6a85fc7 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -81,7 +81,7 @@ Directory is always shown and truncated to the value of `SPACEFISH_DIR_TRUNC`. W | `SPACEFISH_DIR_PREFIX` | `in路` | Prefix before current directory | | `SPACEFISH_DIR_LOCK_SHOW` | `true` | Show directory write-protected symbol | | `SPACEFISH_DIR_LOCK_SYMBOL` | ![路馃敀](https://user-images.githubusercontent.com/11844760/47611530-7bf99c00-da8d-11e8-95da-f4ec1f23203a.png) | The symbol displayed if directory is write-protected (requires powerline patched font) | -| `SPACESHIP_DIR_LOCK_COLOR` | `red` | Color for the lock symbol | +| `SPACEFISH_DIR_LOCK_COLOR` | `red` | Color for the lock symbol | ### Hostname \(`host`\) @@ -89,8 +89,8 @@ Hostname should only be shown while you are connected to another machine using S | Variable | Default | Meaning | | :--- | :---: | --- | -| `SPACEFISH_HOST_SHOW` | `true` | Show host section (true/false) | -| `SPACEFISH_HOST_SHOW_FULL` | `false` | Show full hostname section (true/false) | +| `SPACEFISH_HOST_SHOW` | `true` | Show host section (`true`, `false`, `always`) | +| `SPACEFISH_HOST_SHOW_FULL` | `false` | Show full hostname section (`true`, `false`) | | `SPACEFISH_HOST_PREFIX` | `at路` | Prefix before the hostname | | `SPACEFISH_HOST_SUFFIX` | `$SPACEFISH_PROMPT_DEFAULT_SUFFIX` | Suffix after the hostname | | `SPACEFISH_HOST_COLOR` | `blue` | Color of the hostname | @@ -266,7 +266,7 @@ Elixir section is shown when ```mix.exs``` is found or elixir files are found an | Variable | Default | Meaning | | :------- | :-----: | ------- | -| `SPACESHIP_ELIXIR_SHOW` | `true` | Show current Elixir version | +| `SPACEFISH_ELIXIR_SHOW` | `true` | Show current Elixir version | | `SPACEFISH_ELIXIR_PREFIX` | `$SPACEFISH_PROMPT_DEFAULT_PREFIX` | Prefix before the elixir section | | `SPACEFISH_ELIXIR_SUFFIX` | `$SPACEFISH_PROMPT_DEFAULT_SUFFIX` | Suffix after the elixir section | | `SPACEFISH_ELIXIR_SYMBOL` | `馃挧路` | Character to be shown before Elixir version | @@ -341,7 +341,7 @@ Kubernetes context is shown everywhere if `kubectl` binary is found. | Variable | Default | Meaning | | :------- | :-----: | ------- | | `SPACEFISH_KUBECONTEXT_SHOW` | `true` | Show current kubectl context | -| `SPACESHIP_KUBECONTEXT_NAMESPACE_SHOW` | `true` | Show current kubectl context namespace| +| `SPACEFISH_KUBECONTEXT_NAMESPACE_SHOW` | `true` | Show current kubectl context namespace| | `SPACEFISH_KUBECONTEXT_PREFIX` | `at ` | Prefix before the kubectl section | | `SPACEFISH_KUBECONTEXT_SUFFIX` | `$SPACEFISH_PROMPT_DEFAULT_SUFFIX` | Suffix after the kubectl section | | `SPACEFISH_KUBECONTEXT_SYMBOL` | `鈽革笍 ` | Character to be shown before kubectl context | diff --git a/functions/__sf_section_kubecontext.fish b/functions/__sf_section_kubecontext.fish index c30633f..effb614 100644 --- a/functions/__sf_section_kubecontext.fish +++ b/functions/__sf_section_kubecontext.fish @@ -11,7 +11,7 @@ function __sf_section_kubecontext -d "Display the kubernetes context" # ------------------------------------------------------------------------------ __sf_util_set_default SPACEFISH_KUBECONTEXT_SHOW true - __sf_util_set_default SPACESHIP_KUBECONTEXT_NAMESPACE_SHOW true + __sf_util_set_default SPACEFISH_KUBECONTEXT_NAMESPACE_SHOW true __sf_util_set_default SPACEFISH_KUBECONTEXT_PREFIX "at " __sf_util_set_default SPACEFISH_KUBECONTEXT_SUFFIX $SPACEFISH_PROMPT_DEFAULT_SUFFIX # Additional space is added because 鈽革笍 is wider than other symbols @@ -31,8 +31,8 @@ function __sf_section_kubecontext -d "Display the kubernetes context" set -l kube_context (kubectl config current-context 2>/dev/null) [ -z $kube_context ]; and return - - if test "$SPACESHIP_KUBECONTEXT_NAMESPACE_SHOW" = "true" -a "$kube_context" != "default" + + if test "$SPACEFISH_KUBECONTEXT_NAMESPACE_SHOW" = "true" -a "$kube_context" != "default" set kube_namespace (kubectl config view --minify --output 'jsonpath={..namespace}' 2>/dev/null) set kube_context "$kube_context ($kube_namespace)" end diff --git a/tests/__sf_section_kubecontext.test.fish b/tests/__sf_section_kubecontext.test.fish index d9c6fe5..3b0f340 100644 --- a/tests/__sf_section_kubecontext.test.fish +++ b/tests/__sf_section_kubecontext.test.fish @@ -81,9 +81,9 @@ test "Doesn't display the section when SPACEFISH_KUBECONTEXT_SHOW is set to \"fa ) = (__sf_section_kubecontext) end -test "Doesn't display the namespace section when SPACESHIP_KUBECONTEXT_NAMESPACE_SHOW is set to \"false\"" +test "Doesn't display the namespace section when SPACEFISH_KUBECONTEXT_NAMESPACE_SHOW is set to \"false\"" ( - set SPACESHIP_KUBECONTEXT_NAMESPACE_SHOW false + set SPACEFISH_KUBECONTEXT_NAMESPACE_SHOW false set sf_exit_code 0 set SPACEFISH_KUBECONTEXT_SUFFIX 路 @@ -99,16 +99,18 @@ test "Doesn't display the namespace section when SPACESHIP_KUBECONTEXT_NAMESPACE ) = (__sf_section_kubecontext) end -test "Doesn't display the namespace section when kube_context is set to \"false\"" +test "Doesn't display the namespace section when kube_context is set to \"default\"" ( + mock kubectl config 0 "echo \"default\"" + set sf_exit_code 0 set SPACEFISH_KUBECONTEXT_SUFFIX 路 - set kube_context "default" + set_color --bold echo -n "at " set_color normal set_color --bold cyan - echo -n "鈽革笍 testkube" + echo -n "鈽革笍 default" set_color normal set_color --bold echo -n "路"