updated osx script, cribbed from mathiasbynens