Skip to content

Instantly share code, notes, and snippets.

@wbond
Created September 10, 2012 15:14
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 wbond/3691424 to your computer and use it in GitHub Desktop.
Save wbond/3691424 to your computer and use it in GitHub Desktop.
Script to start rails server on open port and open in Chrome
#!/bin/bash
PORT=3000
while [[ $(netstat -lnt | grep ":$PORT ") != "" ]]; do
PORT=$(($PORT + 1))
done
rails server -p $PORT &
SERVEPID=$!
sleep 2.5
google-chrome http://localhost:$PORT
control_c()
{
kill $SERVEPID
}
trap control_c SIGINT
wait
@wbond
Copy link
Author

wbond commented Sep 10, 2012

I save this file as ~/bin/rsv (with is in my $PATH) and chmod it to 755. Once that is done, I:

cd rails_project
rsv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment