Skip to content

Instantly share code, notes, and snippets.

@swmcc
Created May 27, 2013 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swmcc/5657497 to your computer and use it in GitHub Desktop.
Save swmcc/5657497 to your computer and use it in GitHub Desktop.
A boilerplate tmux shell script I use for including in my projects to aid development. This one isn't specific to any tech other than it uses guard. I might include others that are for node/ruby or even go as far as to specific frameworks express/sinatra/rails.
#!/bin/sh
BASE=`pwd`
PROJECT='xxxxx'
tmux start-server
# new-session creates first window named 'console'
tmux new-session -d -s $PROJECT -n console
# split window 'h'orizontally (into two vertical panes)
tmux split-window -t $PROJECT:console -h
# select the left-most pane
tmux last-pane
# split this pane 'v'ertically (into two horizontal panes)
tmux split-window -t $PROJECT:console -v
# create a second window for 'logs'
tmux new-window -t $PROJECT:2 -n logs
# start a vim editor in the left-most vertical pane
tmux send-keys -t $PROJECT:console.2 "cd $BASE;" C-m
# widen the vim editor pane by 20 cells
tmux resize-pane -L -t $PROJECT:console.2 20
# run guard -c clears shell after each change
tmux send-keys -t $PROJECT:console.0 "cd $BASE; guard -c" C-m
# start rails server
tmux send-keys -t $PROJECT:console.1 "cd $BASE;" C-m
# start logging
tmux send-keys -t $PROJECT:logs "cd $BASE;" C-m
# select the vim pane in the rails window
tmux select-window -t $PROJECT:console
tmux select-pane -t $PROJECT:console.2
# new-session creates a third window named 'dev'
tmux new-window -t $PROJECT:3 -n dev
tmux split-window -t $PROJECT:dev -h
tmux send-keys -t $PROJECT:dev.0 "cd $BASE; vim" C-m
tmux send-keys -t $PROJECT:dev.1 "cd $BASE; vim" C-m
# make the tmux session active
tmux attach-session -d -t $PROJECT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment