Created
March 16, 2017 17:25
-
-
Save cmsj/6fb4e4a8d7edd6c9d89a2d529e52ce5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lastApp = nil | |
function launchFocusOrSwitchBack(appName) | |
-- This function will launch appName if it's not running, focus | |
-- it if it is running, or if it's already focused, switch back | |
-- to whatever the last focused App was | |
-- (The Pro version of this would use hs.windowfilter to track | |
-- window focus events, but for now we'll just assume that this | |
-- is the only way apps will be switched) | |
local currentApp = hs.application.frontmostApplication() | |
if lastApp and currentApp and (currentApp:name() == appName) then | |
lastApp:activate() | |
else | |
hs.application.launchOrFocus(appName) | |
end | |
lastApp = currentApp | |
end | |
hs.hotkey.bind({"cmd", "alt"}, "i", function() launchFocusOrSwitchBack("iTerm") end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment