Skip to content

Instantly share code, notes, and snippets.

@eltercero
Last active June 22, 2019 12:29
Show Gist options
  • Save eltercero/f045fdd9fa56935fa543 to your computer and use it in GitHub Desktop.
Save eltercero/f045fdd9fa56935fa543 to your computer and use it in GitHub Desktop.
Config file for hammerspoon
local hotkey = require "hs.hotkey"
local application = require "hs.application"
-- HOTKEYS
local hyper = {"ctrl", "alt", "cmd"}
local app_opener = {"cmd", "ctrl"}
function toggle_app(app_name)
return function()
local app = hs.appfinder.appFromName(app_name)
if not app then
application.launchOrFocus(app_name)
end
current_app = application.frontmostApplication()
if current_app == app then
app:hide()
else
application.launchOrFocus(app_name)
end
end
end
-- SHORTCUTS
-- Focus or open apps
hotkey.bind( app_opener, "A", toggle_app("Safari") )
hotkey.bind( app_opener, "C", toggle_app("Google Chrome") )
hotkey.bind( app_opener, "S", toggle_app("Sublime Text") )
hotkey.bind( app_opener, "I", toggle_app("iTerm") )
hotkey.bind( app_opener, "L", toggle_app("Slack") )
hotkey.bind( app_opener, "K", toggle_app("Slack") )
hotkey.bind( app_opener, "T", toggle_app("Tweetbot") )
-- Miro Window Management config
-- https://github.com/miromannino/miro-windows-manager
hs.loadSpoon("MiroWindowsManager")
hs.window.animationDuration = 0.3
spoon.MiroWindowsManager:bindHotkeys({
up = {hyper, "up"},
right = {hyper, "right"},
down = {hyper, "down"},
left = {hyper, "left"},
fullscreen = {hyper, "f"}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment