Skip to content

Instantly share code, notes, and snippets.

@mojodna
Last active September 7, 2016 14:44
Show Gist options
  • Save mojodna/1364cf010a0bd08a49e7 to your computer and use it in GitHub Desktop.
Save mojodna/1364cf010a0bd08a49e7 to your computer and use it in GitHub Desktop.
TileMill in bash + AppleScript

TileMill in bash + AppleScript

Installation (OS X)

In the project directory:

npm install tessera tilelive-mapnik tilelive-carto
brew install fswatch

Copy tilemill.scpt and tilemill.sh from this gist into the same directory and run ./tilemill.sh.

Assumptions

make-based build for a map project (e.g. Toner, openstreetmap-carto). If you're using a vanilla TileMill project (with local datasources, i.e. no Millstone), remove make xml and change the map URI to carto+file://./project.mml.

tell application "Google Chrome"
activate
set theUrl to "http://localhost:8080/"
if (count every window) = 0 then
make new window
end if
set found to false
set theTabIndex to -1
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
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
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
#!/bin/sh
PATH=node_modules/.bin:$PATH
while true; do
make xml
tessera mapnik://./project.xml &
pid=$!
# alternately, if make is not in use
# tessera carto+file://./project.mml &
# pid=$!
# give tessera time to start
sleep 1
# comment this out if you don't want Chrome to automatically reload
osascript tilemill.scpt
fswatch -1 .
# kill tessera
kill $pid
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment