Skip to content

Instantly share code, notes, and snippets.

@marclundgren
Created February 25, 2013 18:18
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 marclundgren/5031988 to your computer and use it in GitHub Desktop.
Save marclundgren/5031988 to your computer and use it in GitHub Desktop.
function tunnel {
# Using localtunnel
# https://npmjs.org/package/localtunnel
# Usage:
# tunnel [port [subdomain]]
# tunnel 8080 bzog
local port=${1-"80"};
if [ "$2" != "" ]; then
local subdomain="--subdomain $2";
fi;
local echo_msg="\nTunneling port: $port\nOpenning browser...\n\nExit with Ctrl+C.";
if [ $OSTYPE == "msys" ]; then
sys_exe="start";
elif [ $OSTYPE == "cygwin" ]; then
sys_exe="cygstart";
else
sys_exe="open";
fi;
local awk_cmd='{ system("'$sys_exe' "$4) }';
lt -k ~/.ssh/id_rsa.pub --port $port $subdomain | awk "$awk_cmd" | echo -e $echo_msg;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment