Provide option for setting an environment variable across an entire session

Author: openjckCreated Jul 7, 2020Updated May 3, 2025

Is your feature request related to a problem? Please describe.

I like to set a $PROJECT environment variable when in tmux sessions. The value depends on the session. For example, when I'm in my ensemble session, the value is /home/openjck/dev/ensemble. When I'm in my glam session, the value is /home/openjck/dev/glam. That way, I can move around the file system as needed and simply type cd $PROJECT when I want to return to the root of the project.

I can imagine other use cases for session-wide environment variables like this.

Before I started using tmuxinator, I achieved this with some manually-written tmux commands. It worked some of the time, but it was pretty unreliable. Since then, tmux added an -e flag to new-session which seems to solve this exact problem. If I understand the documentation correctly, it allows an environment variable to be set across an entire session, no matter how many windows or panes are opened or closed.

Describe the solution you'd like

I'd like if the tmuxinator session config file allowed the user to specify an environment variable that would be active across the entire session. That environment variable should be readable from any window or pane, including new windows and panes.

Describe alternatives you've considered

A hook like pre_window could be used, but it wouldn't affect new windows.

Additional context

tmux recently added an optional -e flag to new-session which looks like it's meant for exactly this kind of thing.