Skip to content

Instantly share code, notes, and snippets.

@ksexton
Created January 22, 2013 16:59
Show Gist options
  • Save ksexton/4596267 to your computer and use it in GitHub Desktop.
Save ksexton/4596267 to your computer and use it in GitHub Desktop.
function serve {
local port="${1:-3000}"
local ip=`facter ipaddress`
local address="http://$ip:$port/"
echo "$address" | pbcopy
echo "Serving at $address"
ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => $port, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start" &
sleep 1
open $address
fg %1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment