From 958517dcf4210aefffcafa3cc41f4ebb4edd5e36 Mon Sep 17 00:00:00 2001 From: Mathias Bynens Date: Sat, 31 Dec 2011 11:42:42 +0100 Subject: Replace the `server` alias with a function that optionally takes an argument specifying the port number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inspired by @padolsey’s https://gist.github.com/1525217#gistcomment-71652. --- .functions | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '.functions') diff --git a/.functions b/.functions index a6a576d..4301825 100644 --- a/.functions +++ b/.functions @@ -3,6 +3,13 @@ function md() { mkdir -p "$@" && cd "$@" } +# Start an HTTP server from a directory, optionally specifying the port +function server() { + local port="$1" + [ -z "$port" ] && port=8000 + open "http://localhost:${port}/" && python -m SimpleHTTPServer "$port" +} + # Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. # Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. (Looking at you, ajax.googleapis.com!) function httpcompression() { -- cgit v1.2.3