Skip to content

Commit 62b1a6d

Browse files
Merge branch 'master' into spotify-tui
2 parents 3984f13 + aa14996 commit 62b1a6d

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
3030
- When charging, 'AC' is displayed
3131
- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
3232
- Spotify playback (needs the tool spotify-tui installed)
33+
- Current kubernetes context
3334

3435
## Compatibility
3536

scripts/dracula.sh

100755100644
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ main()
2424
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
2525
show_day_month=$(get_tmux_option "@dracula-day-month" false)
2626
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
27+
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
2728
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
2829

2930
# Dracula Color Pallette
@@ -171,6 +172,10 @@ main()
171172
if [ $plugin = "spotify-tui" ]; then
172173
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray")
173174
script="#($current_dir/spotify-tui.sh)"
175+
176+
if [ $plugin = "kubernetes-context" ]; then
177+
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
178+
script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)"
174179
fi
175180

176181
if [ $plugin = "weather" ]; then

scripts/kubernetes_context.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
# setting the locale, some users have issues with different locales, this forces the correct one
3+
export LC_ALL=en_US.UTF-8
4+
5+
label=$1
6+
7+
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
8+
source $current_dir/utils.sh
9+
10+
current_context=$(kubectl config view --minify --output 'jsonpath={.current-context}'; echo)
11+
current_user=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.user}'; echo)
12+
current_cluster=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.cluster}'; echo)
13+
current_namespace=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.namespace}'; echo)
14+
15+
main()
16+
{
17+
# storing the refresh rate in the variable RATE, default is 5
18+
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
19+
OUTPUT_STRING=""
20+
if [ ! -z "$current_user" ]
21+
then
22+
OUTPUT_STRING="${current_user}@"
23+
fi
24+
25+
if [ ! -z "$current_cluster" ]
26+
then
27+
OUTPUT_STRING="${OUTPUT_STRING}${current_cluster}"
28+
fi
29+
30+
if [ ! -z "$current_namespace" ]
31+
then
32+
OUTPUT_STRING="${OUTPUT_STRING}:${current_namespace}"
33+
fi
34+
35+
if [ "$OUTPUT_STRING" = "" ]
36+
then
37+
OUTPUT_STRING="kubeconfig not valid"
38+
fi
39+
40+
if [ "$label" = "" ]
41+
then
42+
echo "${OUTPUT_STRING}"
43+
else
44+
echo "${label} ${OUTPUT_STRING}"
45+
fi
46+
47+
sleep $RATE
48+
}
49+
50+
# run the main driver
51+
main

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy