diff --git a/.zshrc b/.zshrc index f6df398..8fd021d 100644 --- a/.zshrc +++ b/.zshrc @@ -17,7 +17,10 @@ if [[ -f "$oh_my_zsh/oh-my-zsh.sh" ]]; then ) if [[ $(command -v tmux) ]]; then - if [[ ! -v "ZSH_TMUX_AUTOSTART" ]]; then export ZSH_TMUX_AUTOSTART=true; fi + # Only start/attach if no existing session with client. + if [[ (( $(tmux list-sessions -F "#{session_attached}" 2>/dev/null || echo 0) = 0 )) && ! -v "ZSH_TMUX_AUTOSTART" ]]; then + export ZSH_TMUX_AUTOSTART=true + fi plugins+=(tmux) fi