Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
fix: correct incorrectly named config options (#198)
Browse files Browse the repository at this point in the history
* fix: correct incorrectly named config options

* fix: documentation for hostname options

* fix: use mock to make kubectl test better reflect usage
  • Loading branch information
matchai authored Jul 1, 2019
1 parent 14346b2 commit 85f9ef5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
10 changes: 5 additions & 5 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,16 @@ 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`\)

Hostname should only be shown while you are connected to another machine using SSH, unless you change it using SPACEFISH_HOST_SHOW.

| 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 |
Expand Down Expand Up @@ -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 |
Expand Down Expand Up @@ -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 |
Expand Down
6 changes: 3 additions & 3 deletions functions/__sf_section_kubecontext.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions tests/__sf_section_kubecontext.test.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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 ·

Expand All @@ -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 "·"
Expand Down

0 comments on commit 85f9ef5

Please sign in to comment.