workspace
This commit is contained in:
@@ -1,17 +1,54 @@
|
||||
#!/bin/bash
|
||||
# Start or attach to Claude agent tmux session
|
||||
#!/usr/bin/env bash
|
||||
# Start or attach to tmux agent session (Claude on-demand)
|
||||
|
||||
SESSION_NAME="agent"
|
||||
WORKDIR="/workspace"
|
||||
|
||||
# Load nvm
|
||||
# ---- NVM bootstrap (available, not forced) ----
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
|
||||
# Check if session exists
|
||||
if tmux has-session -t $SESSION_NAME 2>/dev/null; then
|
||||
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
|
||||
else
|
||||
echo "Creating new session: $SESSION_NAME"
|
||||
tmux new-session -s $SESSION_NAME -c /workspace
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user