Skip to content

Instantly share code, notes, and snippets.

@HavenShen
Forked from irazasyed/tunnel-valet.sh
Created September 7, 2017 02:20
Show Gist options
  • Save HavenShen/7fd38bbd0bc3cb2d778db5b26085a300 to your computer and use it in GitHub Desktop.
Save HavenShen/7fd38bbd0bc3cb2d778db5b26085a300 to your computer and use it in GitHub Desktop.
Laravel Valet Share with Sub-Domain Support
# Tunnels to valet project with custom domain name.
# Uses ngrok.com with my personal github account and auth token
function tunnel_valet() {
HOST="${PWD##*/}"
DOMAIN=$(valet domain)
SUBDOMAIN="$HOST"
[[ "$1" ]] && SUBDOMAIN=$1;
for linkname in ~/.valet/Sites/*; do
if [[ "$(readlink $linkname)" = "$PWD" ]]
then
HOST="${linkname##*/}"
fi
done
# Fetch Ngrok URL In Background...
bash valet fetch-share-url &
sudo -u $(logname) ngrok http "$HOST.$DOMAIN:80" -subdomain="$HOST" -host-header=rewrite ${*:2}
exit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment