The original question
Is it possible to override tmux
's default behaviour of executing .[z|bash_]profile
files on every new session, window and pane?
In other words, I'd like it to only execute only the relevant .[zsh|bash]rc
script, i.e. for the new session/window/pane to behave like an xterm
or urxvt
, not like a tty
.
More specifically (edit)
I'd like to avoid changing anything to my .*profile
and .*rc
scripts. I'm looking for a way to ask tmux
to open non-login shells in its new sessions, windows and panes by properly configuring it in .tmux.conf
, in order to keep the prior philosophy of putting only actual 'login' instructions on .*profile
scripts, as recommended for instance here: What should/shouldn't go in .zshenv, .zshrc, .zlogin, .zprofile, .zlogout?
I am aware on how to circumvent the issue by hacking e.g. .zprofile
as was answered to Changing tmux .bash_profile behavior , but the question is of how to do it from .tmux.conf
Secondary question
Why does tmux
load the .*profile
scripts by default, on every session, window and pane, whereas subshells on any context and all (or at least most) variants of X terminals don't?
Some background information (not necessarily relevant)
I barely started using tmux
(only occasionally, for now), but I do have an ever-evolving setup, using zsh
as my shell of choice, in which .zprofile
expects to be called from a tty
and do relevant stuff (like deciding to run startx
or not based on whether it's on a laptop and the tty number), the .zshrc
script expects to be called from any interactive environment and the .zshenv
script expects to be loaded whether on an interactive environment or not.
EDIT: Solution (based on comments below)
Adding the following line to .tmux.conf
overrides tmux
's behaviour and defaults to starting non-login interactive shells (zsh in this case) on new
sessions, windows and panes:
set-option -g default-command zsh
.bash_profile
, it's the shell that reads it. – Marco Oct 21 '13 at 19:45.zshrc
is evaluated in interactive login and non-logins shells. To only evaluate code in login shells use.zlogin
and to change the tmux behaviour to use non-login shells useset-option -g default-command 'zsh'
. – Marco Oct 21 '13 at 21:25