Skip to content

Instantly share code, notes, and snippets.

@johnmeehan
Created January 30, 2014 20:01
Show Gist options
  • Save johnmeehan/8717582 to your computer and use it in GitHub Desktop.
Save johnmeehan/8717582 to your computer and use it in GitHub Desktop.
Tmux - Rails - MongoDB set up shell script
#!/bin/sh
# John Meehan 2013
#
# DESCRIPTION:
# Setups up tmux, Rails server and MongoDB
# USEAGE:
# Put this script within the main directory of a Rails App
# Call ./tmux_setup.sh to run
# This name's the project the name of the rails app and your login name
# i.e vitasparks-JohnMeehan
# Making it easier to find the right session when working in pairs
project=${PWD##*/}"-"$USER
# use $USER to name the project after whomever is logged in
# Make a new session called vitasparks and detach from it, Name the Window Servers
tmux new-session -d -s $project -n Servers
# Split the window vertically targeting vitasparks
tmux split-window -h -t $project
# Select the right hand pane
tmux select-pane -t 1
#tmux select-pane -R -t $project
# Check if there isa mongoid.yml file in config. if so then run below.
# C-m is carriage return
tmux send-keys -t $project 'mongod --dbpath ~/Documents/data/db' C-m
# Select the left hand pane
tmux select-pane -t 0
tmux send-keys -t $project 'rails server' C-m
#add a new window targeting vitasparks name the window vim and open vim
#tmux new-window -t $project -n 'vim' 'vim'
# Attach to the session
tmux attach -t $project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment