Launching an SSH login right into tmux
Topics: Secure Shell
For SSH logins, the .zlogin snippet starts or attaches to a tmux session named for the user and avoids nesting when already inside tmux.
Add the following code to your ~/.zlogin file:
# Relaunch SSH session in tmux
if which tmux >/dev/null && [[ -z "$TMUX" ]] && [[ -n "$SSH_CONNECTION" ]]; then
exec tmux new -A -s $(whoami)
fi