Skip to content

Instantly share code, notes, and snippets.

@Dima-369
Created February 7, 2021 18:41
Show Gist options
  • Save Dima-369/41e5c89a77e2f489ab0359dc8263d18e to your computer and use it in GitHub Desktop.
Save Dima-369/41e5c89a77e2f489ab0359dc8263d18e to your computer and use it in GitHub Desktop.
Take a screenshot of the current window, save to /Desktop and open Finder in Hammerspoon
-- using real hyper with shift breaks some hotkeys for whatever reason
hyper = {"cmd", "alt", "ctrl"}
-- Take a screenshot of the current window
hs.hotkey.bind(hyper, "d", function()
file_name = "screenshot-" .. os.time() .. ".png"
hs.window.focusedWindow():snapshot():saveToFile(os.getenv("HOME") .. "/Desktop/" .. file_name)
title = hs.window.focusedWindow():title()
hs.alert.show(title .. "\n\n Saved screenshot as " .. file_name)
hs.execute('open ~/Desktop/')
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment