-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmux-logs.sh
More file actions
executable file
·31 lines (25 loc) · 1.17 KB
/
Copy pathtmux-logs.sh
File metadata and controls
executable file
·31 lines (25 loc) · 1.17 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
#!/bin/bash
SESSION_NAME="bookapp-logs"
# Kill the session if it already exists to ensure a clean start
tmux has-session -t $SESSION_NAME 2>/dev/null
if [ $? = 0 ]; then
tmux kill-session -t $SESSION_NAME
fi
# Create a new detached session with a window named "Docker"
# The initial pane is 0
tmux new-session -d -s $SESSION_NAME -n "Docker"
# Create the 2x2 layout
# Split pane 0 vertically, creating pane 1 below it
tmux split-window -v -t $SESSION_NAME:Docker.0
# Split the top pane (0) horizontally, creating pane 2 to its right
tmux split-window -h -t $SESSION_NAME:Docker.0
# Split the bottom pane (1) horizontally, creating pane 3 to its right
tmux split-window -h -t $SESSION_NAME:Docker.1
# Now we have 4 panes, indexed 0, 2, 1, 3 (top-left, top-min, top-right, bottom)
# Send the commands to the correct panes
tmux send-keys -t $SESSION_NAME:Docker.0 "docker logs -f bookapp-backend" C-m
tmux send-keys -t $SESSION_NAME:Docker.2 "docker logs -f bookapp-frontend" C-m
tmux send-keys -t $SESSION_NAME:Docker.1 "docker logs -f bookapp-proxy" C-m
tmux send-keys -t $SESSION_NAME:Docker.3 "docker ps -a" C-m
# Attach to the session to view it
tmux attach-session -t $SESSION_NAME