Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# ideal for textmate bundle, reloads the current tab's CSS
# JS via
refreshScript=`cat <<'JAVASCRIPT'
void(function(){var i,a,s;a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {var h=s.href.replace(/(&|\\\?)forceReload=\\\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}}})();
# Check if Safari is running, if so refresh CSS
ps -xc|grep -sq Safari && osascript <<APPLESCRIPT
tell app "Safari"
do JavaScript "$refreshScript" in document 1
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.