First, install CookiesTool to a location of your choice (by default the script looks for ~/bin/CookiesTool
).
Then download the script below.
curl --proto "=https" --tlsv1.2 "https://gist.githubusercontent.com/msanders/365b06cbc2f9c63981f4ab88234cd330/raw/safari_clear_cookies" -o /path/to/safari_clear_cookies
chmod u+x /path/to/safari_clear_cookies
To automatically invoke when Safari exits, you can use add this to Hammerspoon:
local eventTable <const> = {
[hs.application.watcher.terminated] = function()
hs.task.new(
os.getenv("HOME")
..
"/.config/hammerspoon/scripts/safari_clear_cookies"
, nil):start()
end
}
watcher = hs.application.watcher.new(function(app, event, _)
if app:bundleID() == "com.apple.Safari" then
local fn = eventTable[event]
if fn ~= nil then fn() end
end
end):start()
Homebrew environment variables can be passed to Hammerspoon via:
launchctl setenv HOMEBREW_PREFIX "$HOMEBREW_PREFIX"
Or via shell config.
jq
brew install jq
To clear Safari cache, run:
rm -rf "$HOME/Library/Containers/com.apple.Safari/Data/Library/Caches/com.apple.Safari/"
rm -rf "$HOME/Library/Caches/com.apple.Safari/"
Currently incompatible with tab grouping.
This is made available under the terms of the MIT license. For a copy, see https://opensource.org/licenses/MIT.