Created
January 24, 2017 14:30
-
-
Save drewtempelmeyer/1051ab3a92faa0968c297468300b8f87 to your computer and use it in GitHub Desktop.
Automatically set up development environment for Rails/Ember applications
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 | |
# 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