-
-
Save wbond/3691424 to your computer and use it in GitHub Desktop.
Script to start rails server on open port and open in Chrome
This file contains 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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I save this file as
~/bin/rsv
(with is in my$PATH
) and chmod it to 755. Once that is done, I: