From 5d230abfd7903982ef518a7699de136ac65d6084 Mon Sep 17 00:00:00 2001 From: Kevin Cotugno Date: Fri, 16 Feb 2024 13:15:27 -0700 Subject: [PATCH] Only start tmux if there is no client currently attached --- .zshrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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