From 8c7c37d65b6bce8663850558482bae3671eaf956 Mon Sep 17 00:00:00 2001 From: druckdev Date: Wed, 8 Sep 2021 13:39:10 +0200 Subject: [PATCH] zsh:zprofile: Attach to tmux only when it exists --- .config/zsh/.zprofile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/zsh/.zprofile b/.config/zsh/.zprofile index aa8ebfb..1d3cfcb 100644 --- a/.config/zsh/.zprofile +++ b/.config/zsh/.zprofile @@ -104,7 +104,9 @@ if command -v startx &>/dev/null && [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then fi # Attach to tmux session if connected over ssh and not already attached -if [[ (-n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION) && -z $TMUX ]]; then +if (( $+commands[tmux] )) && + [[ (-n $SSH_CLIENT || -n $SSH_TTY || -n $SSH_CONNECTION) && -z $TMUX ]] +then num_sessions="$(tmux list-sessions 2>/dev/null | wc -l)" if (( ! num_sessions )); then