Merge branch 'master' into spotify-tui
This commit is contained in:
commit
62b1a6d0a4
3 changed files with 57 additions and 0 deletions
|
@ -30,6 +30,7 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
|
|||
- When charging, 'AC' is displayed
|
||||
- If forecast information is available, a ☀, ☁, ☂, or ❄ unicode character corresponding with the forecast is displayed alongside the temperature
|
||||
- Spotify playback (needs the tool spotify-tui installed)
|
||||
- Current kubernetes context
|
||||
|
||||
## Compatibility
|
||||
|
||||
|
|
5
scripts/dracula.sh
Executable file → Normal file
5
scripts/dracula.sh
Executable file → Normal file
|
@ -24,6 +24,7 @@ main()
|
|||
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
|
||||
show_day_month=$(get_tmux_option "@dracula-day-month" false)
|
||||
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
|
||||
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
|
||||
|
||||
# Dracula Color Pallette
|
||||
|
@ -171,6 +172,10 @@ main()
|
|||
if [ $plugin = "spotify-tui" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-spotify-tui-colors" "green dark_gray")
|
||||
script="#($current_dir/spotify-tui.sh)"
|
||||
|
||||
if [ $plugin = "kubernetes-context" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
|
||||
script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)"
|
||||
fi
|
||||
|
||||
if [ $plugin = "weather" ]; then
|
||||
|
|
51
scripts/kubernetes_context.sh
Executable file
51
scripts/kubernetes_context.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
label=$1
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
current_context=$(kubectl config view --minify --output 'jsonpath={.current-context}'; echo)
|
||||
current_user=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.user}'; echo)
|
||||
current_cluster=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.cluster}'; echo)
|
||||
current_namespace=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.namespace}'; echo)
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
OUTPUT_STRING=""
|
||||
if [ ! -z "$current_user" ]
|
||||
then
|
||||
OUTPUT_STRING="${current_user}@"
|
||||
fi
|
||||
|
||||
if [ ! -z "$current_cluster" ]
|
||||
then
|
||||
OUTPUT_STRING="${OUTPUT_STRING}${current_cluster}"
|
||||
fi
|
||||
|
||||
if [ ! -z "$current_namespace" ]
|
||||
then
|
||||
OUTPUT_STRING="${OUTPUT_STRING}:${current_namespace}"
|
||||
fi
|
||||
|
||||
if [ "$OUTPUT_STRING" = "" ]
|
||||
then
|
||||
OUTPUT_STRING="kubeconfig not valid"
|
||||
fi
|
||||
|
||||
if [ "$label" = "" ]
|
||||
then
|
||||
echo "${OUTPUT_STRING}"
|
||||
else
|
||||
echo "${label} ${OUTPUT_STRING}"
|
||||
fi
|
||||
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run the main driver
|
||||
main
|
Loading…
Reference in a new issue