Serve static files in a current directory and create $current_dir.dev
host name.
~/Sites/usercss.ru ➤ pow
open http://usercss.ru.dev/
~/Sites/n12v.com/static ➤ pow n12v
open http://n12v.dev/
Serve static files in a current directory and create $current_dir.dev
host name.
~/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 |