Skip to content

Commit

Permalink
Update custom color depending on context (#24)
Browse files Browse the repository at this point in the history
In README.md example, the color does not change when the value of the
variable is changed.
  • Loading branch information
superbrothers authored Nov 3, 2020
1 parent 3f56f85 commit 76c595c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ For example, make the prompt red when the username matches admin.
```sh
autoload -U colors; colors
source /path/to/zsh-kubectl-prompt/kubectl.zsh
[[ "$ZSH_KUBECTL_USER" =~ "admin" ]] && color=red || color=blue
RPROMPT='%{$fg[$color]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}'
function right_prompt() {
local color="blue"

if [[ "$ZSH_KUBECTL_USER" =~ "admin" ]]; then
color=red
fi

echo "%{$fg[$color]%}($ZSH_KUBECTL_PROMPT)%{$reset_color%}"
}
RPROMPT='$(right_prompt)'
```

Also you can install with homebrew.
Expand Down

0 comments on commit 76c595c

Please sign in to comment.