#!/bin/bash SESSION="cluster" CONFIG_FILE="$HOME/.ssh/tmux-hosts.conf" if [ ! -f "$CONFIG_FILE" ]; then echo "Config file not found: $CONFIG_FILE" exit 1 fi # Kill existing session tmux kill-session -t $SESSION 2>/dev/null # Create new session tmux new-session -d -s $SESSION -n "Control" tmux set -t $SESSION -g mouse on tmux set -t $SESSION -g pane-border-status top # Count hosts host_count=0 while IFS=: read -r name connection port description; do [[ -z "$name" || "$name" =~ ^# ]] && continue ((host_count++)) done < "$CONFIG_FILE" multiview_window=$((host_count + 1)) # Create individual host windows window_num=1 hosts=() while IFS=: read -r name connection port description; do [[ -z "$name" || "$name" =~ ^# ]] && continue port=${port:-22} hosts+=("$name:$connection:$port:$description") tmux new-window -t $SESSION:$window_num -n "$name" tmux select-pane -t $SESSION:$window_num.0 -T "$description" if [ "$port" != "22" ]; then tmux send-keys -t $SESSION:$window_num "ssh -p $port $connection" C-m else tmux send-keys -t $SESSION:$window_num "ssh $connection" C-m fi ((window_num++)) done < "$CONFIG_FILE" # Create multi-view window if [ ${#hosts[@]} -gt 0 ]; then tmux new-window -t $SESSION:$multiview_window -n "Multi-View" num_hosts=${#hosts[@]} for ((i=1; i