.hammerspoon/init.lua

Mon, 22 May 2017 20:52:28 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 22 May 2017 20:52:28 -0400
changeset 579
0cb7adee16fe
parent 520
a6a39c406585
child 620
ce78d743489f
permissions
-rw-r--r--

move begin into function too

493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 hs.window.animationDuration = 0
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 function reloadConfig(files)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4 hs.reload()
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 end
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", reloadConfig):start()
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 local bindKey = hs.hotkey.bind
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 local cmd = hs.fnutils.partial(bindKey, {"cmd"})
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 local cmdShift = hs.fnutils.partial(bindKey, {"cmd", "shift"})
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
11 local cmdCtrl = hs.fnutils.partial(bindKey, {"cmd", "ctrl"})
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 cmdShift('r', reloadConfig)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
15 function focusedWindow() return hs.window.focusedWindow() or hs.window.desktop() end
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
16 function focusTo(direction) hs.window['focusWindow' .. direction](focusedWindow()) end
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 cmd('k', function () focusTo('North') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 cmd('up', function () focusTo('North') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 cmd('j', function () focusTo('South') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22 cmd('down', function () focusTo('South') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 cmd('h', function () focusTo('West') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25 cmd('left', function () focusTo('West') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27 cmd('l', function () focusTo('East') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28 cmd('right', function () focusTo('East') end)
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
30 cmdShift('up', function () focusedWindow():maximize() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
31
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
32 cmdShift('down', function () focusedWindow():minimize() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
33
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
34 cmdShift('left', function () focusedWindow():moveToUnit(hs.layout.left50) end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
35 cmdShift('right', function () focusedWindow():moveToUnit(hs.layout.right50) end)
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
37 cmdCtrl('left', function () focusedWindow():moveOneScreenWest() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
38 cmdCtrl('right', function () focusedWindow():moveOneScreenEast() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
39
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
40 cmd('return', function ()
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
41 hs.applescript.applescript([[
500
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
42 tell application "iTerm"
520
a6a39c406585 Get new window focused
Meredith Howard <mhoward@roomag.org>
parents: 500
diff changeset
43 set newterm to (create window with default profile)
a6a39c406585 Get new window focused
Meredith Howard <mhoward@roomag.org>
parents: 500
diff changeset
44 tell newterm to activate
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
45 end tell
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
46 ]])
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
47 end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
48
500
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
49 -- cache window frames before moving?
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
50 -- save cache?
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
51 -- focus by direction is a little strict
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
52

mercurial