0
votes

I'm just trying to pass current zsh environment to tmux session. I have RUST_BACKTRACE=1 in .zprofile. I did like below.

Create a new session like below.

tmux new -d -s ipython ipython

Attache to the session.

Then check what environment variables it has.

In [1]: import os

In [2]: os.environ.copy()
Out[2]: 
(No RUST_BACKTRACE environemnt.)

Apparently, the environment variable is not same as zsh's ones. Is there any way to make tmux load .zprofile or something like that kind of file?

1
I currently use this command. tmux new -d -s ipython zsh -c "source .zshrc;ipython"fx-kirin
If you create a child process, it inherits the environment from the parent. Verify, by doing a printenv RUST_BACKTRACE), right before doing the tmux, that this environment variable exists.user1934428
Keep in mind the client/server architecture of tmux. The server inherits your environment when it is first started. After than, any new session inherits its environment from the server, not the environment of your client when you reattach. The update-environment session option lets you specify a list of environment variables which the client should request the server to update for that session.chepner

1 Answers

0
votes

Thanks to @chepner in a comment, I added command below to .tmux.conf and everything seems working fine. Thanks!

run-shell "cat ~/.zprofile | sed -n 's/export *\\(.*\\)=\\(.*\\)/tmux set-environment -g \\1 \\2/e'"