Skip to content

Instantly share code, notes, and snippets.

@patrickng
Last active December 20, 2015 10:59
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 patrickng/6119765 to your computer and use it in GitHub Desktop.
Save patrickng/6119765 to your computer and use it in GitHub Desktop.
Shell script for serving current directory
# Put in .bashrc, .zshrc, or .profile
function serve {
port="${1:-3000}"
open "http://localhost:${port}/" && ruby -r webrick -e "s = WEBrick::HTTPServer.new(:Port => $port, :DocumentRoot => Dir.pwd); trap('INT') { s.shutdown }; s.start"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment