Skip to content

Instantly share code, notes, and snippets.

@drewtempelmeyer
Created January 24, 2017 14:30
Show Gist options
  • Save drewtempelmeyer/1051ab3a92faa0968c297468300b8f87 to your computer and use it in GitHub Desktop.
Save drewtempelmeyer/1051ab3a92faa0968c297468300b8f87 to your computer and use it in GitHub Desktop.
Automatically set up development environment for Rails/Ember applications
#!/bin/bash
# Set up variables
run_server=true
show_help=false
# Set up the server command
if [ -f 'ember-cli-build.js' ]; then
SERVER_CMD='ember server --proxy http://localhost:3000'
elif [ -f 'bin/rails' ]; then
SERVER_CMD='bin/rails s'
fi
# Options
while getopts 'nh' flag; do
case "${flag}" in
n) run_server=false ;;
h) show_help=true ;;
*) error "Unexpected option ${flag}" ;;
esac
done
# Show command usage
show_usage ()
{
echo "$(basename "$0") [-h] [-n] -- creates a tmux environment for Ember and Rails applications
where:
-h show this help text
-n don't launch Ember/Rails server"
}
# Show the command usage and exit
if [ "$show_help" == true ]; then
show_usage
exit 0
fi
# Set up tmux session
tmux new-session -d 'vim'
if [ "$run_server" = false ] || [ -z "$SERVER_CMD" ]; then
tmux split-window -v
else
tmux split-window -v "$SERVER_CMD"
fi
tmux split-window -h
tmux -2 attach-session -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment