-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev
More file actions
executable file
·58 lines (45 loc) · 1.58 KB
/
dev
File metadata and controls
executable file
·58 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
USAGE="Usage: dev [-p <path>]"
EDITOR_CMD="${EDITOR:-nvim}"
show_help() {
echo "$USAGE"
echo ""
echo " -p <path> Path to working directory (default: current directory)"
echo " -h Show this help message"
exit 0
}
while getopts "p:h" opt; do
case $opt in
p) PROJECT_PATH="$OPTARG" ;;
h) show_help ;;
*) echo "$USAGE" >&2; exit 1 ;;
esac
done
PROJECT_PATH="${PROJECT_PATH:-.}"
if [ ! -d "$PROJECT_PATH" ]; then
echo "Error: '$PROJECT_PATH' is not a valid directory" >&2
exit 1
fi
PROJECT_PATH="$(cd "$PROJECT_PATH" && pwd)"
SESSION_NAME="dev-$(basename "$PROJECT_PATH")"
if [ -n "$TMUX" ]; then
echo "Error: already inside a tmux session. Detach first or run from outside tmux." >&2
exit 1
fi
tmux kill-session -t "$SESSION_NAME" 2>/dev/null
# Window 1: EDITOR
tmux new-session -d -s "$SESSION_NAME" -c "$PROJECT_PATH" -n "editor"
tmux send-keys -t "$SESSION_NAME:editor" "$EDITOR_CMD" Enter
# Window 2: AI Workflow
tmux new-window -t "$SESSION_NAME" -n "pi" -c "$PROJECT_PATH"
tmux send-keys -t "$SESSION_NAME:pi" 'pi' Enter
tmux split-window -h -t "$SESSION_NAME:pi" -c "$PROJECT_PATH"
tmux send-keys -t "$SESSION_NAME:pi" 'pi' Enter
# Window 3: Scripts / Git / Extra Terminal Panes
tmux new-window -t "$SESSION_NAME" -n "extra" -c "$PROJECT_PATH"
tmux split-window -h -t "$SESSION_NAME:extra" -c "$PROJECT_PATH"
tmux select-pane -t "$SESSION_NAME:extra.1"
tmux split-window -v -t "$SESSION_NAME:extra" -c "$PROJECT_PATH"
tmux select-pane -t "$SESSION_NAME:extra.0"
tmux select-window -t "$SESSION_NAME:editor"
tmux attach -t "$SESSION_NAME"