What I Want
I'm trying to automate connecting to a remote machine in multiple, separate ssh terminals and have independent tmux sessions for each remote terminal while sharing the same windows (i.e. can change session settings and active window/pane without affecting other remote terminals while still having access to the same tmux windows).
I want to do this without changing how the tmux executable is initially run and entirely in a per-user way (all changes limited to /home/$USER/
).
How I'm Trying To Accomplish It
Ubuntu 16.04
TMUX 2.1 (from package manager)
I'm using MS's port of ssh
(OpenSSH) on my local system (Windows 10).
Currently when I open a remote terminal (or a local terminal for that matter) tmux is launched via ~/.zprofile
and creates an entirely new session. I have a ~/.tmux.conf
file with the following line:
#(this is a single line in my .tmux.conf, I've broken it up here for readability)
if-shell 'tmux has-session -t theonering' \
'new-session -t theonering' \
'rename-session theonering'
I'm, also setting destroy-unattached on
at the session level in that second line, but I left it out for clarity here. It doesn't change the outcome.
What I Expect To Happen
This states, to the best of my understanding, that "if, from a shell, tmux says it has a session named theonering
then create a new (unnamed) session and group it with theonering
. if tmux does not have a session named theonering
renamed the current session to theonering
."
What Actually Happens
Now if I connect remotely, detach from the existing session, then run the above command (prefixed with tmux
, obviously)? Works great.
But if I put it in my ~/.tmux.conf
? bupkiss. It's the same as if the line wasn't there at all. No error, no message, no deviation from stock behavior.