.hammerspoon/init.lua

changeset 908
fa7c0607c00e
parent 907
df71b104b773
child 987
556f618e117a
equal deleted inserted replaced
907:df71b104b773 908:fa7c0607c00e
13 function focusTo(direction) 13 function focusTo(direction)
14 local fn = hs.getObjectMetatable('hs.window')['focusWindow' .. direction] 14 local fn = hs.getObjectMetatable('hs.window')['focusWindow' .. direction]
15 return function () 15 return function ()
16 fn(focusedWindow(), nil, nil, true) 16 fn(focusedWindow(), nil, nil, true)
17 end 17 end
18 end
19
20 function findOrLaunch(a)
21 return hs.application.find(a) or hs.application.open(a, 3)
18 end 22 end
19 23
20 -- and the key bindings 24 -- and the key bindings
21 cmdShift('r', hs.reload) 25 cmdShift('r', hs.reload)
22 26
41 45
42 cmdCtrl('left', function () focusedWindow():moveOneScreenWest() end) 46 cmdCtrl('left', function () focusedWindow():moveOneScreenWest() end)
43 cmdCtrl('right', function () focusedWindow():moveOneScreenEast() end) 47 cmdCtrl('right', function () focusedWindow():moveOneScreenEast() end)
44 48
45 cmd('return', function () 49 cmd('return', function ()
46 hs.applescript.applescript([[ 50 local a = findOrLaunch('iTerm')
47 tell application "iTerm" 51 a:selectMenuItem({"Shell", "New Window"})
48 set newterm to index of (create window with default profile) 52 a:activate()
49 tell application "System Events" to tell process "iTerm2"
50 perform action "AXRaise" of window newterm
51 end tell
52 end tell
53 ]])
54 end) 53 end)
55 54
56 cmdShift('return', function () 55 cmdShift('return', function ()
57 os.execute(os.getenv('SHELL')..' -l -i -c "exec mvim"') 56 os.execute(os.getenv('SHELL')..' -l -i -c "exec mvim"')
58 end) 57 end)
59 58
60 -- cache window frames before moving? 59 cmdCtrl('return', function ()
61 -- save cache? 60 local a = findOrLaunch('MacVim')
62 -- focus by direction is a little strict 61 a:selectMenuItem({"File", "New Window"})
63 62 a:activate()
63 end)

mercurial