Skip to content

Instantly share code, notes, and snippets.

@ericrallen
Last active December 25, 2015 03:18
Show Gist options
  • Save ericrallen/6908422 to your computer and use it in GitHub Desktop.
Save ericrallen/6908422 to your computer and use it in GitHub Desktop.
copy xip.io URL for current project to clipboard
-- generates xip.io url with optional port
-- I store this script in my ~/bin directory and then use `ln -s ~/bin/xip.io.scpt` to create a symbolic link in the folder for my current project
-- Here's the funciton in my ~/.bashrc file:
-- function xipit() {
-- port=$@
-- if [ ! -f xip.io.scpt ]; then
-- ln -s ~/bin/xip.io.scpt;
-- fi
-- osascript xip.io.scpt $port;
-- }
-- call it like this `xipit :3000` to get an xip.io URL with the port set to 3000
--ALFRED USERS: Here's an Alfred workflow based off the previous version of this AppleScript: http://cl.ly/3I28263K3k3t (author's Twitter handle: @DanPhilibin)
on run argv
-- get IP address
set tIP to do shell script "ifconfig en0|grep 'inet '|cut -d ' ' -f 2"
if(tIP is "") then
set tIP to do shell script "ifconfig en1|grep 'inet '|cut -d ' ' -f 2"
end if
-- get current directory
set currentDir to do shell script "echo ${PWD##*/}"
-- set url
if (count of argv) > 0 then
set urlString to "http://" & currentDir & "." & tIP & ".xip.io" & item 1 of argv
else
set urlString to "http://" & currentDir & "." & tIP & ".xip.io"
end if
-- add url to clipboard
set the clipboard to urlString
do shell script "echo " & urlString
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment