Skip to content

Instantly share code, notes, and snippets.

@montethinks
Last active February 21, 2024 11:27
Show Gist options
  • Save montethinks/2f4c43c900b6df5160422b4013d7c93f to your computer and use it in GitHub Desktop.
Save montethinks/2f4c43c900b6df5160422b4013d7c93f to your computer and use it in GitHub Desktop.
Start tmux with preconfigured windows and panes.
#!/bin/sh
# Setup a work space called `work` with four windows
session="work"
# set up tmux
tmux start-server
# create a new tmux session with <NAME>
tmux new-session -d -s $session -n servers
# Select pane 1, set dir to <PROJECT NAME>
tmux selectp -t 1
tmux send-keys "cd ~/path/to/project" C-m
# Select pane 2
tmux splitw -h
tmux send-keys "cd ~/path/to/project" C-m
# create a new window called <PROJECT NAME>
tmux new-window -t $session:2 -n <PROJECT NAME>
tmux send-keys "cd ~/path/to/project" C-m
tmux send-keys "vim ." C-m
# create a new window called <PROJECT NAME>
tmux new-window -t $session:3 -n <PROJECT NAME>
tmux send-keys "cd ~/path/to/project" C-m
tmux send-keys "vim ." C-m
# create a new window called <PROJECT NAME>
tmux new-window -t $session:4 -n scratch
# return to main servers window
tmux select-window -t $session:1
# Finished setup, attach to the tmux session!
tmux attach-session -t $session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment