Is there a way or command to clear the Hammerspoon Console?
I'd love to be able to 'reset' the console each time I reload the Config.
Thoughts?
@latenitefilms, hs.console.clearConsole() ?
Perfect, thanks @junkblocker !
Sorry... I missed the hs.console section in the API documentation. My bad!
Still, a little toolbar button would be super nice to have...
You can easily add a "clear" button yourself.
See: https://github.com/CommandPost/CommandPost/blob/develop/src/extensions/cp/init.lua#L107
Thanks @latenitefilms
It was a bit of a head scratcher for me, but I eventually figured out what I was doing wrong. For anyone else who might benefit, here's the code I inserted into my init.lua to get a Clear button on the Console:
-- custom Console toolbar (adds Clear button)
local toolbar = require("hs.webview.toolbar")
local console = require("hs.console")
local image = require("hs.image")
console.defaultToolbar = toolbar.new("CustomToolbar", {
{ id="prefs", label="Preferences", image=image.imageFromName("NSPreferencesGeneral"), tooltip="Open Preferences", fn=function() hs.openPreferences() end },
{ id="reload", label="Reload config", image=image.imageFromName("NSSynchronize"), tooltip="Reload configuration", fn=function() hs.reload() end },
{ id="openCfg", label="Open config", image=image.imageFromName("NSActionTemplate"), tooltip="Edit configuration", fn=function() openConfig() end },
{ id="clearLog", label="Clear", image = hs.image.imageFromName("NSTrashEmpty"), tooltip="Clear Console", fn=function() console.clearConsole() end },
{ id="help", label="Help", image=image.imageFromName("NSInfo"), tooltip="Open API docs browser", fn=function() hs.doc.hsdocs.help() end }
}):canCustomize(true):autosaves(true)
console.toolbar(console.defaultToolbar)
function openConfig()
hs.open(hs.configdir .. "/init.lua")
end
Most helpful comment
Thanks @latenitefilms
It was a bit of a head scratcher for me, but I eventually figured out what I was doing wrong. For anyone else who might benefit, here's the code I inserted into my init.lua to get a Clear button on the Console: