Skip to content

Instantly share code, notes, and snippets.

@jdcantrell
Created December 19, 2013 09:08
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 jdcantrell/8036482 to your computer and use it in GitHub Desktop.
Save jdcantrell/8036482 to your computer and use it in GitHub Desktop.
local dev bash functions
#Local dev site functions
#find current directory in our list of sites
function dev-find {
pwd=$(pwd)
for link in $(ls ~/.sites)
do
if [[ $pwd = $(readlink -f ~/.sites/$link) ]]; then
echo $link
break
fi
done
}
#if this directory is not already a site create it
#$1 - a name for the site, defaults to current directory name
function dev-mk {
link=$(dev-find)
if [[ -z $link ]]; then
name=${1:-$(basename $(pwd))}
if [! -f ~/.sites/$name ]; then
ln -s $(pwd) ~/.sites/$name
fi
echo "http://$name.dev"
else
echo "http://$link.dev"
fi
}
#open dev site in ff (and create it first if needed)
function dev-ff {
firefox $(dev-mk $1)
}
#get xip.io url
function xip {
ip=$(ifconfig p5p1 | grep -Eo 'inet [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | cut -d ' ' -f2)
link=$(dev-find)
echo "http://$link.$ip.xip.io"
}
#use icanhazip.com to get your external ip
function xip-all {
ip=$(curl icanhazip.com)
link=$(dev-find)
echo "http://$link.$ip.xip.io"
}
#open xip.io url in FF
function xip-ff {
firefox $(xip)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment