Skip to content

Instantly share code, notes, and snippets.

@NV
Last active December 22, 2015 03:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NV/6408693 to your computer and use it in GitHub Desktop.
Save NV/6408693 to your computer and use it in GitHub Desktop.
Command-line tool for pow!

Serve static files in a current directory and create $current_dir.dev host name.

Usage

~/Sites/usercss.ru ➤ pow
open http://usercss.ru.dev/

~/Sites/n12v.com/static ➤ pow n12v
open http://n12v.dev/
#!/bin/sh
if [ -z $1 ]; then
host=$(basename $PWD)
else
host=$1
fi
exist_error () {
echo "$1 already exist" 1>&2
exit 1
}
open_in_browser () {
echo "open http://$1.dev/"
open "http://$1.dev/"
}
path="$HOME/.pow/$host"
if [ -e $path ]; then
if [ -d $path -a -L "$path/public" ]; then
realpath=$(readlink "$path/public")
if [ "$PWD" = "$realpath" ]; then
open_in_browser $host
exit 0
else
exist_error $path
fi
else
exist_error $path
fi
fi
mkdir -p $path
echo "$path/public -> $PWD"
ln -s $PWD "$path/public"
open_in_browser $host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment