mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-07-17 16:52:24 +00:00
Merge pull request #53 from prabhu43/master
Configure highlight color for current context & namespace
This commit is contained in:
commit
428fb0045c
13
README.md
13
README.md
@ -118,6 +118,19 @@ wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packa
|
||||
|
||||
-----
|
||||
|
||||
### Customizing current context colors
|
||||
|
||||
If you like to customize the colors indicating the current namespace or context, set the environment variables `KUBECTX_CURRENT_FGCOLOR` and `KUBECTX_CURRENT_BGCOLOR`:
|
||||
|
||||
```
|
||||
export KUBECTX_CURRENT_FGCOLOR=$(tput setaf 6) # blue text
|
||||
export KUBECTX_CURRENT_BGCOLOR=$(tput setaf 7) # white background
|
||||
```
|
||||
|
||||
Refer color codes [here](https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/)
|
||||
|
||||
-----
|
||||
|
||||
#### Users
|
||||
|
||||
| What are others saying about kubectx? |
|
||||
|
6
kubectx
6
kubectx
@ -58,9 +58,13 @@ list_contexts() {
|
||||
darkbg=$(tput setab 0)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
local cur_ctx_fg cur_ctx_bg
|
||||
cur_ctx_fg=${KUBECTX_CURRENT_FGCOLOR:-$yellow}
|
||||
cur_ctx_bg=${KUBECTX_CURRENT_BGCOLOR:-$darkbg}
|
||||
|
||||
for c in $(get_contexts); do
|
||||
if [[ -t 1 && "${c}" = "${cur}" ]]; then
|
||||
echo "${darkbg}${yellow}${c}${normal}"
|
||||
echo "${cur_ctx_bg}${cur_ctx_fg}${c}${normal}"
|
||||
else
|
||||
echo "${c}"
|
||||
fi
|
||||
|
6
kubens
6
kubens
@ -109,12 +109,16 @@ list_namespaces() {
|
||||
darkbg=$(tput setab 0)
|
||||
normal=$(tput sgr0)
|
||||
|
||||
local cur_ctx_fg cur_ctx_bg
|
||||
cur_ctx_fg=${KUBECTX_CURRENT_FGCOLOR:-$yellow}
|
||||
cur_ctx_bg=${KUBECTX_CURRENT_BGCOLOR:-$darkbg}
|
||||
|
||||
local cur ns_list
|
||||
cur="$(current_namespace)"
|
||||
ns_list=$(get_namespaces)
|
||||
for c in $ns_list; do
|
||||
if [[ -t 1 && "${c}" = "${cur}" ]]; then
|
||||
echo "${darkbg}${yellow}${c}${normal}"
|
||||
echo "${cur_ctx_bg}${cur_ctx_fg}${c}${normal}"
|
||||
else
|
||||
echo "${c}"
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user