diff --git a/.commonrc b/.commonrc index 445e1f5..ceadb26 100755 --- a/.commonrc +++ b/.commonrc @@ -1,17 +1,8 @@ [[ -f "$HOME/.dotfiles/aliases" ]] && source "$HOME/.dotfiles/aliases" -if [ -z "$TMUX" ]; then - base_session='main' - # Create a new session if it doesn't exist - tmux has-session -t $base_session || tmux new-session -d -s $base_session - # Are there any clients connected already? - client_cnt=$(tmux list-clients | wc -l) - if [ $client_cnt -ge 1 ]; then - session_name=$base_session"-"$client_cnt - tmux new-session -d -t $base_session -s $session_name - tmux -2 attach-session -t $session_name \; set-option destroy-unattached - else - tmux -2 attach-session -t $base_session +if [ ! "$TERM_PROGRAM" = "iTerm.app" ]; then + if [ -z "$TMUX" ]; then + (tmux ls | grep -vq attached && tmux -2 attach-session -t main) || tmux -2 new-session -t main fi fi