From dad48e53979c9d4728e2bdb548c944d6e2541f31 Mon Sep 17 00:00:00 2001 From: Prabhu Jayakumar Date: Mon, 28 May 2018 23:03:03 +0530 Subject: [PATCH 1/4] Use * to indicate current context & current namespace --- kubectx | 2 +- kubens | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kubectx b/kubectx index f181552..9eba150 100755 --- a/kubectx +++ b/kubectx @@ -60,7 +60,7 @@ list_contexts() { for c in $(get_contexts); do if [[ -t 1 && "${c}" = "${cur}" ]]; then - echo "${darkbg}${yellow}${c}${normal}" + echo "* ${darkbg}${yellow}${c}${normal}" else echo "${c}" fi diff --git a/kubens b/kubens index cbf26a7..e3e3383 100755 --- a/kubens +++ b/kubens @@ -114,7 +114,7 @@ list_namespaces() { ns_list=$(get_namespaces) for c in $ns_list; do if [[ -t 1 && "${c}" = "${cur}" ]]; then - echo "${darkbg}${yellow}${c}${normal}" + echo "* ${darkbg}${yellow}${c}${normal}" else echo "${c}" fi From c23c2a9e29ff85ca6c5c81475fd0fce3a8d9ae70 Mon Sep 17 00:00:00 2001 From: Prabhu Jayakumar Date: Wed, 30 May 2018 00:32:23 +0530 Subject: [PATCH 2/4] Revert "Use * to indicate current context & current namespace" This reverts commit dad48e53979c9d4728e2bdb548c944d6e2541f31. --- kubectx | 2 +- kubens | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kubectx b/kubectx index 9eba150..f181552 100755 --- a/kubectx +++ b/kubectx @@ -60,7 +60,7 @@ list_contexts() { for c in $(get_contexts); do if [[ -t 1 && "${c}" = "${cur}" ]]; then - echo "* ${darkbg}${yellow}${c}${normal}" + echo "${darkbg}${yellow}${c}${normal}" else echo "${c}" fi diff --git a/kubens b/kubens index e3e3383..cbf26a7 100755 --- a/kubens +++ b/kubens @@ -114,7 +114,7 @@ list_namespaces() { ns_list=$(get_namespaces) for c in $ns_list; do if [[ -t 1 && "${c}" = "${cur}" ]]; then - echo "* ${darkbg}${yellow}${c}${normal}" + echo "${darkbg}${yellow}${c}${normal}" else echo "${c}" fi From 9beb1a1587c7f9f0b41e925b57f2ea2425e85ff2 Mon Sep 17 00:00:00 2001 From: Prabhu Jayakumar Date: Wed, 30 May 2018 01:07:39 +0530 Subject: [PATCH 3/4] Configure highlight color for current context & namespace using environment variable --- README.md | 15 +++++++++++++++ kubectx | 6 +++++- kubens | 6 +++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82e8412..378d34c 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,21 @@ Active namespace is "default". ----- +### Highlight Current Context +By default, current context is highlighted by yellow foreground & black background + +It is configurable by setting environment variables `KUBECTX_CURRENT_FGCOLOR` & `KUBECTX_CURRENT_BGCOLOR` + +To change foreground colour to Blue for highlighting current context: + +`export KUBECTX_CURRENT_FGCOLOR=$(tput setaf 6)` + +To change background colour to White for highlighting current context: + +`export KUBECTX_CURRENT_FGCOLOR=$(tput setaf 7)` + +Refer color codes [here](https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/) + ## Installation ### macOS diff --git a/kubectx b/kubectx index f181552..f625d75 100755 --- a/kubectx +++ b/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 diff --git a/kubens b/kubens index cbf26a7..628181b 100755 --- a/kubens +++ b/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 From a97ab8367db7361f0265b4241acff65ec2f3d1a1 Mon Sep 17 00:00:00 2001 From: Prabhu Jayakumar Date: Fri, 8 Jun 2018 00:35:45 +0530 Subject: [PATCH 4/4] Update Readme --- README.md | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 378d34c..0dcbd12 100644 --- a/README.md +++ b/README.md @@ -73,21 +73,6 @@ Active namespace is "default". ----- -### Highlight Current Context -By default, current context is highlighted by yellow foreground & black background - -It is configurable by setting environment variables `KUBECTX_CURRENT_FGCOLOR` & `KUBECTX_CURRENT_BGCOLOR` - -To change foreground colour to Blue for highlighting current context: - -`export KUBECTX_CURRENT_FGCOLOR=$(tput setaf 6)` - -To change background colour to White for highlighting current context: - -`export KUBECTX_CURRENT_FGCOLOR=$(tput setaf 7)` - -Refer color codes [here](https://linux.101hacks.com/ps1-examples/prompt-color-using-tput/) - ## Installation ### macOS @@ -133,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? |