I noticed something peculiar while working with multiple tmux sessions. I'm not certain on all the terminology so please correct me if I get something wrong.
Creating tmux sessions beyond the first does not inherit the environment it was created from, they inherit the environment that spawned the first session.
export a=false; export b=false
bash
export a=true
tmux new-session -d -s first
bash
export b=true
tmux new-session -d -s second
then executing echo $a $b
from either session gives the output true false
. I was expecting true true
for the second session.
I don't know how tmux "remembers" the environment of the first session. I can perform another experiment:
If I update the environment in the first session, detach, and spawn a second session, the second session does not inherit the update.
And another experiment:
If I exit the subshell after creating the first session (thus "forgetting" the environment variable a
), and spawn a second session, the second session still remembers the environment.
I'd like to better know why this is happening and some of what tmux is doing under-the-hood, so any advice in that direction is appreciated.