55 lines
1.7 KiB
Bash
Executable File
55 lines
1.7 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"
|
|
'
|
|
|
|
# ---- 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"
|
|
|
|
# Pane 0: Main shell (editor / ssh / control)
|
|
tmux send-keys -t "$SESSION_NAME:0.0" "cd $WORKDIR && clear" C-m
|
|
tmux send-keys -t "$SESSION_NAME:0.0" "$NVM_LOAD" C-m
|
|
|
|
# Pane 1: Right (AI / ssh / tools)
|
|
tmux split-window -h -t "$SESSION_NAME:0" -c "$WORKDIR"
|
|
tmux send-keys -t "$SESSION_NAME:0.1" "$NVM_LOAD" C-m
|
|
tmux send-keys -t "$SESSION_NAME:0.1" "echo 'AI / tools pane (run claude manually)'" C-m
|
|
|
|
# Pane 2: Bottom-left (review / second shell)
|
|
tmux select-pane -t "$SESSION_NAME:0.0"
|
|
tmux split-window -v -c "$WORKDIR"
|
|
tmux send-keys -t "$SESSION_NAME:0.2" "$NVM_LOAD" C-m
|
|
tmux send-keys -t "$SESSION_NAME:0.2" "echo 'Review / ssh pane'" C-m
|
|
|
|
# Pane 3: Bottom (tests / logs)
|
|
tmux select-pane -t "$SESSION_NAME:0.0"
|
|
tmux split-window -v -c "$WORKDIR"
|
|
tmux send-keys -t "$SESSION_NAME:0.3" "$NVM_LOAD" C-m
|
|
tmux send-keys -t "$SESSION_NAME:0.3" "echo 'Tests / logs pane'" C-m
|
|
|
|
# ---- Layout & focus ----
|
|
tmux select-layout -t "$SESSION_NAME" tiled
|
|
tmux select-pane -t "$SESSION_NAME:0.0"
|
|
|
|
# ---- Attach ----
|
|
tmux attach-session -t "$SESSION_NAME"
|