Last active
August 27, 2018 10:12
-
-
Save davebarkerxyz/7233970 to your computer and use it in GitHub Desktop.
Scripting tmux to set up my development environment The script opens 3 windows:
1 - a vim session for backend work; 2 - a vim session for frontend work; 3 - split into 2x2, with two bash shells, one postgresql shell and my Python/Flask application running in the fourth pane;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEV_PATH="~/dev/myapp" | |
SESSION="myapp" | |
tmux -2 new-session -d -s $SESSION | |
# First window (backend dev) | |
tmux rename-window "Backend" | |
tmux send-keys "cd $DEV_PATH; vim" C-m | |
# Frontend window for vim | |
tmux new-window -n "Frontend" | |
tmux send-keys "cd $DEV_PATH; vim" C-m | |
# Control window | |
tmux new-window -n "Control" | |
# Split to 2x2 | |
tmux split-window -h | |
tmux split-window -v | |
tmux select-pane -t 0 | |
tmux split-window -v | |
# First pane | |
tmux select-pane -t 0 | |
tmux send-keys "cd $DEV_PATH" C-m | |
# Second pane | |
tmux select-pane -t 1 | |
tmux send-keys "cd $DEV_PATH" C-m | |
# Third pane | |
tmux select-pane -t 2 | |
tmux send-keys "cd $DEV_PATH; scripts/db_shell.sh" C-m | |
# Fourth pane | |
tmux select-pane -t 3 | |
tmux send-keys "cd $DEV_PATH; ./run.py" C-m | |
# Select the control window and first pane | |
tmux select-window -t "Control" | |
tmux select-pane -t 0 | |
# Reattach | |
tmux -2 attach-session -t $SESSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment