diff options
author | Sindre Sorhus <sindresorhus@gmail.com> | 2012-08-07 11:13:45 +0200 |
---|---|---|
committer | Mathias Bynens <mathias@qiwi.be> | 2012-08-07 11:14:15 +0200 |
commit | 378fa5bec44d3b93b3b170e6f27f5e89c277e2e2 (patch) | |
tree | 7ef1441be1c2cb1fd6d6dc5c8538d9fe08b4fab0 | |
parent | 5d76fc286fe921cddf9a73c404ada924c856df24 (diff) | |
download | dotfiles-378fa5bec44d3b93b3b170e6f27f5e89c277e2e2.tar.gz dotfiles-378fa5bec44d3b93b3b170e6f27f5e89c277e2e2.tar.bz2 dotfiles-378fa5bec44d3b93b3b170e6f27f5e89c277e2e2.zip |
.functions: Add `phpserver`
Ref. #116.
-rw-r--r-- | .functions | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -29,6 +29,15 @@ function server() { python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" } +# Start a PHP server from a directory, optionally specifying the port +# (Requires PHP 5.4.0+.) +function phpserver() { + local port="${1:-4000}" + local ip=$(ipconfig getifaddr en1) + sleep 1 && open "http://${ip}:${port}" & + php -S "${ip}:${port}" +} + # Get gzipped file size function gz() { echo "orig size (bytes): " |