Bring All Finder Windows To Front With Hammerspoon

One annoyance with macOS is switching to the Finder in Alfred only brings one window forward. Others remain hidden behind the prior app.

I'm solving that with Hammerspoon. This snippet triggers the "Bring All to Front" menu item in the Finder whenever it's activated.

~/.hammerspoon/bring-finder-to-front.lua

local function finderWatcher(app, event, appObj) 
  if app == "Finder" then
    if event == hs.application.watcher.activated then
      appObj:selectMenuItem("Bring All to Front")
    end
  end
end

local appWatcher = hs.application.watcher.new(finderWatcher)
appWatcher:start()

References