tmuxviewer/tmux_viewer.sh

51 lines
902 B
Bash
Raw Normal View History

2022-01-17 11:33:57 +01:00
#!/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
view_session
2022-01-17 11:33:57 +01:00
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