Created
February 8, 2014 19:24
-
-
Save ph3nx/8888806 to your computer and use it in GitHub Desktop.
Shell script to generate an rails app with postgres database in osx mavericks.
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 | |
case "$1" in | |
"n" ) | |
if [ -z $2 ] | |
then | |
echo "Specify an app name" | |
else | |
if [ -d ~/rails/$2 ] | |
then | |
echo "App '$2' exists already" | |
else | |
rails new "~/rails/$2" -d postgresql | |
psql --command="create database $2;" | |
ln -s ~/rails/$2 ~/.pow/ | |
open http://"$2".dev | |
cd ~/rails/$2 | |
subl ~/rails/$2 | |
fi | |
fi | |
;; | |
"r" ) | |
if [ -z $2 ] | |
then | |
echo "Specify an app name" | |
else | |
if [ -d /rails/$2 ] | |
then | |
echo "Removing app $2" | |
t=$(date +%Y-%m-%d-%s) | |
mv ~/rails/$2 ~/rails_bak/$2-$t | |
rm ~/.pow/$2 | |
echo "Created backup in ~/rails_bak/$2-$t" | |
else | |
echo "App '$2' not found" | |
fi | |
fi | |
;; | |
"o" ) | |
if [ -z $2 ] | |
then | |
echo "Specify an app name" | |
else | |
if [ -d /rails/$2 ] | |
then | |
echo "Opening app.." | |
open http://$2.dev | |
cd ~/rails/$2 | |
subl ~/rails/$2 | |
else | |
echo "App '$2' not found" | |
fi | |
fi | |
;; | |
*) | |
echo "There is no command like '$1'" | |
cat << EOF | |
Create App: | |
n app | |
Remove App | |
r app | |
Open App | |
o app | |
EOF | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment