Direnv does not work if shell initializes tmux #29851
-
I have a line in my config that initializes a tmux session when my shell loads: exec tmux new-session -A -s "$USER" But unfortunately this apparently interferes with the direnv loading process, causing the following error: 2025-05-04T07:25:30+00:00 ERROR [project::environment] login shell exited with exit status: 1
2025-05-04T07:25:30+00:00 ERROR [project::environment] Login shell exited with nonzero exit code. See logs for details Removing the line initializing the tmux session allows direnv to work again. Is there a way to detect when the shell is being run by zed's direnv process, so that I can selectively skip tmux? I still want tmux to initialize in zed's actual terminal pane, so hopefully there's a way to distinguish between the two. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Figured out a good solution, you can check if the shell is connected to a terminal before executing if tty -s; then
exec tmux new-session -A -s "$USER"
fi This way |
Beta Was this translation helpful? Give feedback.
Figured out a good solution, you can check if the shell is connected to a terminal before executing
tmux
:This way
tmux
will still load in zed's terminal pane.