2

Let's say I am using a tmux window with 4 panes (like the example in this question. Now I change some environment variable and I want the new value to be recognized in all 4 panes. Is there a simple way to respawn all 4 panes with one command?

I know that :respawn-pane -k works for any one pane, but it's tiresome to have to enter it 4 times. I also tried respawn-window, but that left me with a single new pane (it killed my 4-pane view).

Thanks

1
  • That's an interesting idea. I seem to recall wondering if there was a tmux solution to propagating an environment variable change across open shells a few years ago, but I didn't find one at the time. Don't recall considering :respawn-pane though, so maybe the solution lies along that path. My solution ended up being a change from zsh to fish (for this and other reasons). fish has "universal variables" which take effect in all open shells when set/changed. – NotTheDr01ds May 13 at 17:40
1

If nothing else, it seems to be easily scriptable:

bash/zsh: for pane in $(tmux list-panes -a -F "#D"); do tmux respawn-pane -k -t $pane; done

fish: for pane in (tmux list-panes -a -F "#D"); tmux respawn-pane -k -t $pane; end

As I'm sure you are aware, this should be used with caution since it will end any and all processes that are running in any of the other panes.

1
  • Thanks, that's a good idea. I'm going to leave the question open a little longer (i.e., not accept the answer yet) to see if someone comes up with a way to do it natively in tmux. I appreciate your suggestion. – John May 16 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.