Skip to content
zimbatm edited this page Nov 10, 2019 · 4 revisions

It is recommended to wrap tmux to avoid issues with environment loading.

In Bash / ZSH:

alias tmux='direnv exec / tmux'

In Fish:

alias tmux "direnv exec / tmux"

This will make sure that direnv is unloaded before executing tmux, and avoid issues with environment variables mangling in tmux's subshells.

Alternatively

NOTE: this solution will not revert to the original environment if a direnv-managed folder was entered before invoking tmux.

Rather than aliasing tmux, you can try adding these lines to .tmux.conf or /etc/tmux.conf:

set-option -g update-environment "DIRENV_DIFF DIRENV_DIR DIRENV_WATCHES"
set-environment -gu DIRENV_DIFF
set-environment -gu DIRENV_DIR
set-environment -gu DIRENV_WATCHES
set-environment -gu DIRENV_LAYOUT
Clone this wiki locally