jonmosco / kube-tmux

Kubernetes status line for tmux
Apache License 2.0
345 stars 46 forks source link

How can I dynamically set the context #8

Open tao12345666333 opened 5 years ago

tao12345666333 commented 5 years ago

I have multiple clusters.

I can connect each other by seting KUBECONFIG environment variable.

The script can get correct output, like this:

(MoeLove) ➜  ~ echo $KUBECONFIG
/home/tao/.kube/kind-config-1
(MoeLove) ➜  ~ sh ~/workspace/kube-tmux/kube.tmux 
#[fg=blue]⎈ #[fg=colour]#[fg=]kubernetes-admin@kind-1#[fg=colour250]:#[fg=]default
(MoeLove) ➜  ~ KUBECONFIG=/home/tao/.kube/config 
(MoeLove) ➜  ~ sh ~/workspace/kube-tmux/kube.tmux 
#[fg=blue]⎈ #[fg=colour]#[fg=]minikube#[fg=colour250]:#[fg=]default

But the tmux status bar can not get correct result. I know that it did not get the correct environment variable when it executed. And I want to know how can I do this?
Thanks!

jonmosco commented 5 years ago

Hmm, what does your .tmux.conf look like where you are calling the script? Can you paste it here?

tao12345666333 commented 5 years ago

Thanks for your reply. I just put the script to my local path $HOME/workspace/kube-tmux/kube.tmux .


set -g status-left '[#(whoami)]'
set -g status-right '[#(date +" %m-%d %H:%M ") #(getbat.sh) #(/bin/bash $HOME/workspace/kube-tmux/kube.tmux 250 red cyan)]'
set -g status-justify "centre"

set -g pane-active-border-fg '#55ff53'
set -g pane-border-fg '#7fcfee'
mcadam commented 4 years ago

Having the same issue, any updates?