#!/bin/bash VIEWER="tmuxviewer" SOCKETS="/tmp/$VIEWER/" SESSIONS="$(ls $SOCKETS)" HOSTNAME="$(hostname).$(grep domain /etc/resolv.conf | cut -d " " -f 2)" function select_session () { if [ $(echo $SESSIONS | wc -w) == 1 ]; then SOCKET=$SOCKETS$SESSIONS echo $SOCKET else echo "please choose a session to view: (or exit to quit)" select session in $(echo $SESSIONS); do if [ -n "$session" ]; then SOCKET=$SOCKETS$session echo "connection to $session at $SOCKET" view_session else case $REPLY in exit) echo "will quit now" break;; *) echo "refreshing list..." select_session ;; esac fi done fi } function view_session () { clear while : do tmux -S $SOCKET attach -t shared -r 2>/dev/null clear echo "$HOSTNAME is not broadcasting at $SOCKET..." sleep 1 done } function main () { select_session } main