Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
on run {input, parameters}
tell application "Terminal"
set currentTab to do script ("ps ax | grep jekyll | grep -v grep | awk '{ print $1 }' | xargs kill") in front window
set currentTab to do script ("jekyll serve --detach;") in front window
end tell
tell application "Google Chrome"
activate
set theUrl to "http://0.0.0.0:4000/"
if (count every window) = 0 then
make new window
end if
set found to false
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL starts with theUrl then
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
delay 0.7
tell theTab to reload
set theWindow's active tab index to theTabIndex
set index of theWindow to 1
else
tell window 1 to make new tab with properties {URL:theUrl}
end if
end tell
tell application "Sublime Text"
activate
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment