local module = {}

module.init = function()
	hs.hotkey.bind({"cmd", "shift"}, "space", function()

		local focusedApp = hs.application.frontmostApplication()
		if focusedApp:name() == 'iTerm2' then
			focusedApp:hide()
		else
			hs.application.open("iTerm")
		end
	end)

	hs.hotkey.bind({'ctrl', 'alt', 'shift'}, 'space', function()

		local focusedApp = hs.application.frontmostApplication()
		if focusedApp:name() == 'Dynalist' then
			focusedApp:hide()
		else
			hs.application.open('Dynalist')
		end
	end)
end

return module

local module = {}

appLauncher = function (bundleID)
	return function()
		local focusedApp = hs.application.frontmostApplication()

		if focusedApp:bundleID() == bundleID then
			focusedApp:hide()
		else
			hs.application.open(bundleID)
		end
	end
end

module.init = function()
	hs.hotkey.bind({'cmd', 'shift'}, 'space', appLauncher('com.googlecode.iterm2'))
	hs.hotkey.bind({'ctrl', 'alt', 'shift'}, 'space', appLauncher('io.dynalist'))
end

return module

Create reusable function for launching apps
Create reusable function for launching apps

Switched to bundleID because the name for iTerm is 'iTerm2' but it needs
to be `open()`ed with 'iTerm' (dunno why)
