.hammerspoon/init.lua

Tue, 26 Sep 2017 13:29:00 -0400

author
Meredith Howard <mhoward@roomag.org>
date
Tue, 26 Sep 2017 13:29:00 -0400
changeset 647
eabafa02cdb2
parent 644
42383cfcb729
child 648
2918ff726641
permissions
-rw-r--r--

easier thread controls

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
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
3 -- set up reload on modify
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
4 hs.pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon/", hs.reload):start()
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
6 -- aliases and partial bindings to make life easier
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7 local bindKey = hs.hotkey.bind
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 local cmd = hs.fnutils.partial(bindKey, {"cmd"})
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 local cmdShift = hs.fnutils.partial(bindKey, {"cmd", "shift"})
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
10 local cmdCtrl = hs.fnutils.partial(bindKey, {"cmd", "ctrl"})
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
12 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
13 function focusTo(direction) hs.window['focusWindow' .. direction](focusedWindow()) end
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
15 -- and the key bindings
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
16 cmdShift('r', hs.reload)
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
17
493
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
644
42383cfcb729 add cmd-shift-return for quick mvim windows
Meredith Howard <mhoward@roomag.org>
parents: 620
diff changeset
49 cmdShift('return', function () os.execute('/opt/local/bin/mvim') end)
42383cfcb729 add cmd-shift-return for quick mvim windows
Meredith Howard <mhoward@roomag.org>
parents: 620
diff changeset
50
500
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
51 -- cache window frames before moving?
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
52 -- save cache?
efce0f59ef14 Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents: 495
diff changeset
53 -- 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
54

mercurial