Skip to content

Instantly share code, notes, and snippets.

Last active Dec 25, 2015
What would you like to do?
copy URL for current project to clipboard
-- generates url with optional port
-- I store this script in my ~/bin directory and then use `ln -s ~/bin/` 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 ]; then
-- ln -s ~/bin/;
-- fi
-- osascript $port;
-- }
-- call it like this `xipit :3000` to get an URL with the port set to 3000
--ALFRED USERS: Here's an Alfred workflow based off the previous version of this AppleScript: (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 & "" & item 1 of argv
set urlString to "http://" & currentDir & "." & tIP & ""
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