- Adăugat cleanup automat pentru socket tmux stale (după restart container) - Corectat indexarea window/pane pentru base-index 1 - Simplificat layout-ul la 2 panouri fără send-keys Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
42 lines
1.1 KiB
Bash
Executable File
42 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Start or attach to tmux agent session (Claude on-demand)
|
|
|
|
SESSION_NAME="agent"
|
|
WORKDIR="/workspace"
|
|
|
|
# ---- NVM bootstrap (available, not forced) ----
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
|
|
|
NVM_LOAD='
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
'
|
|
|
|
# ---- Clean stale socket if tmux server is dead ----
|
|
TMUX_SOCK="/tmp/tmux-$(id -u)/default"
|
|
if [ -e "$TMUX_SOCK" ] && ! tmux ls &>/dev/null; then
|
|
rm -f "$TMUX_SOCK"
|
|
fi
|
|
|
|
# ---- Attach if exists ----
|
|
if tmux has-session -t "$SESSION_NAME" 2>/dev/null; then
|
|
echo "Attaching to existing session: $SESSION_NAME"
|
|
tmux attach-session -t "$SESSION_NAME"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Creating new session: $SESSION_NAME"
|
|
|
|
# ---- Create session ----
|
|
tmux new-session -d -s "$SESSION_NAME" -c "$WORKDIR"
|
|
|
|
# ---- Enable mouse (click between panes + scroll) ----
|
|
tmux set-option -g mouse on
|
|
|
|
# Pane 2: Right
|
|
tmux split-window -h -t "$SESSION_NAME:1" -c "$WORKDIR"
|
|
|
|
# ---- Focus left pane & attach ----
|
|
tmux select-pane -t "$SESSION_NAME:1.1"
|
|
tmux attach-session -t "$SESSION_NAME" |