Editor: BBEdit. Cmd+B is hooked to the following AppleScript for my project:
tell application "BBEdit"
save front document
end tell
tell application "Terminal"
if (count of windows) is 0 then
do script "/path.to.my/make.command"
else
do script "/path.to.my/make.command" in window 1
end if
end tell
tell application "Google Chrome"
activate
end tell
My make.command (simplified):
#!/bin/sh
coffee -c mycode.coffee
lessc -x mycode.less > mycode.css
rsync -avz --delete --force --exclude ".DS*"
-e "ssh my.ppk" /localpath/www user@me.com:/remotepath/www
On my server, I run a changed.php file:
function fileHash($fn) {
echo sprintf("%u.", crc32(file_get_contents(dirname(__FILE__) . $fn)));
}
header('Access-Control-Allow-Origin: *');
fileHash('mycode.js');
fileHash('mycode.css');
On all my HTML pages, I run this piece of CoffeeScript (compiled above to JS):
# defined elsewhhere:
# debugmode (bool)
# reloadIfChangedLast (empty string)
# getCurrentView() returns #pageHashURL
reloadIfChanged = ->
if not debugmode
return false
$.ajax
type: 'GET'
url: 'me.com/changed.php?rnd=' + Math.random()
error: ->
setTimeout reloadIfChanged, 500
return
success: (data) ->
if reloadIfChangedLast and data and
reloadIfChangedLast isnt data
reloadIfChangedLast = data
document.location.href = 'index.html?rnd=' +
Math.random() +
'#' + getCurrentView()
else
if data
reloadIfChangedLast = data
setTimeout reloadIfChanged, 500
return
return
It may seem like a lot of hassle but for me it's just copy-paste and edit a few things per project. And the benefits are tremendous.