irongit
bash-help/tmux-session-gen.sh
61 lines2.0 KBBourne Again Shell (bash)
1#!/bin/bash
2# set window_is_new for new windows
3# make this executable in home directory
4# then you just do ./session.sh from root to open
5
6is_new_window=true
7
8function new_pane() {
9 if [ "$is_new_window" = false ]; then
10 tmux split-window
11 tmux select-layout tiled
12 fi
13
14 tmux send-keys "source ~/.fb_bashrc" C-m
15 tmux send-keys 'printf "\033]2;'"$1"'\033\\"' C-m
16 tmux send-keys "clear" C-m
17 tmux send-keys "$2" C-m
18 is_new_window=false
19}
20
21tmux new-session -d -s fb -n portforwarding
22new_pane "RDS Port Forwarding" 'autossh -L 9101:$RDS_HOST:5432 fb'
23new_pane "Metabase Port Forwarding" "autossh -L 9006:127.0.0.1:9006 fb"
24
25tmux new-window -n libraries
26is_new_window=true
27new_pane "Flyingbytes Root" "cd ~/code/flyingbytes"
28new_pane "Django Server" "cd ~/code/flyingbytes/flyingbytes"
29new_pane "Turbobid" "cd ~/code/flyingbytes/rustlib/turbobid"
30new_pane "Rlib Auth" "cd ~/code/flyingbytes/rustlib/auth"
31new_pane "Rlib Fedex" "cd ~/code/flyingbytes/rustlib/fedex"
32new_pane "Rlib Live Logger" "cd ~/code/flyingbytes/rustlib/live_logger"
33new_pane "Rlib Utils" "cd ~/code/flyingbytes/rustlib/utils"
34new_pane "Rlib User Calendar" "cd ~/code/flyingbytes/rustlib/user_calendar"
35
36tmux new-window -n connections
37is_new_window=true
38new_pane "Local Server" "cd $FB_ROOT
39docker compose down --remove-orphans
40docker compose up -d
41docker compose logs -f --tail 1000 web"
42new_pane "Dev Server" 'autossh fbdev
43cd flyingbytes/server
44docker compose logs -f --tail 100 web'
45new_pane "Production Server" 'autossh fb
46cd flyingbytes/servers/main
47docker compose logs -f --tail 100 web'
48new_pane "Local Database" 'psql $LOCAL_DB_URL'
49new_pane "Dev Database" 'psql $DEV_DB_URL'
50new_pane "Production Database" 'psql $PROD_DB_URL'
51
52tmux new-window -n playground
53is_new_window=true
54new_pane "FB Root 1" 'cd code/flyingbytes'
55new_pane "FB Root 2" 'cd code/flyingbytes'
56new_pane "FB Root 3" 'cd code/flyingbytes'
57new_pane "Home 1" ""
58new_pane "Home 2" ""
59new_pane "Home 3" ""
60
61tmux attach -t "fb:1"