hs: fix iterm/tmux keybinds
This commit is contained in:
parent
d8c5bcc323
commit
cb15dabd04
|
@ -1,13 +1,16 @@
|
|||
|
||||
local tmux_prefix = {{'ctrl'}, 'c'}
|
||||
|
||||
-- Helpers
|
||||
local function isTmuxWindow()
|
||||
return function ()
|
||||
hs.window.focusedWindow():title():find("tmux")
|
||||
local win = hs.window.focusedWindow()
|
||||
if win then
|
||||
return win:title():find("tmux")
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function tmuxpresskey(mod, key)
|
||||
local function tmuxPressKey(mod, key)
|
||||
if isTmuxWindow() then
|
||||
hs.eventtap.keyStroke({'ctrl'}, 'c')
|
||||
hs.eventtap.keyStroke(mod, key)
|
||||
|
@ -30,17 +33,29 @@ App.new("iTerm2")
|
|||
end)
|
||||
end
|
||||
|
||||
-- new window
|
||||
-- new tmux window
|
||||
self.bind({'cmd'}, 'n', function()
|
||||
if not tmuxpresskey({}, 'c') then
|
||||
app:selectMenuItem({"Shell", "New Window"})
|
||||
if not tmuxPressKey({}, 'c') then
|
||||
App.find("iTerm2"):selectMenuItem({"Shell", "New Window"})
|
||||
end
|
||||
end)
|
||||
|
||||
-- new window
|
||||
self.bind({'cmd', 'shift'}, 'n', function()
|
||||
App.find("iTerm2"):selectMenuItem({"Shell", "New Window"})
|
||||
end)
|
||||
|
||||
-- close pane/window
|
||||
self.bind({'cmd'}, 'w', function()
|
||||
if not tmuxpresskey({}, 'x') then
|
||||
app:selectMenuItem({"Shell", "Close"})
|
||||
if not tmuxPressKey({}, 'x') then
|
||||
App.find("iTerm2"):selectMenuItem({"Shell", "Close"})
|
||||
end
|
||||
end)
|
||||
|
||||
-- detach tmux before quitting iterm
|
||||
self.bind({'cmd'}, 'q', function()
|
||||
if not tmuxPressKey({}, 'd') then
|
||||
App.find("iTerm2"):kill()
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
|
Loading…
Reference in a new issue