2026-08-12
tmux attach new

tmux wrapper to either attach to server or start new if it doesn't exist

#!/bin/sh -Cfu


set -Cfu


tmux=tmux

tmux_alt_bin="$HOME/tmux"


if [ -x "$tmux_alt_bin" ]
then
	tmux="$tmux_alt_bin"
fi


$tmux has > /dev/null 2>&1


case "$?"
in
	0) exec $tmux attach                      ;;
	1) exec $tmux new                         ;;
	*) echo "$0: internal error" >&2 ; exit 1 ;;
esac

use with eg

exec tan

perhaps symlink into ~/bin/

ln -svi directory/tmux-attach-new.sh ~/bin/tan

created [1786482716] 2026-08-12 00:11:56 +0300/EEST, modified [1786484036] 2026-08-12 00:33:56 +0300/EEST