SOCKET_PATH="/var/tmux_share/shared"

# Connect to tmux if a session exists
tmux -S $SOCKET_PATH attach -t shared

# If a session didn't exist, delete the socket we created
[ $? -ne 0 ] && rm -f $SOCKET_PATH

# Exit, either when exiting tmux or after failing to connect
exit