Mon, 29 Jun 2020 16:25:06 -0500
Add TigLog
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 | 3 | -- set up reload on modify |
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 | 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 | 15 | -- and the key bindings |
16 | cmdShift('r', hs.reload) | |
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" |
705
7520062c1461
okay -actually- get it to focus the new window
Meredith Howard <mhoward@roomag.org>
parents:
648
diff
changeset
|
43 | set newterm to index of (create window with default profile) |
7520062c1461
okay -actually- get it to focus the new window
Meredith Howard <mhoward@roomag.org>
parents:
648
diff
changeset
|
44 | tell application "System Events" to tell process "iTerm2" |
7520062c1461
okay -actually- get it to focus the new window
Meredith Howard <mhoward@roomag.org>
parents:
648
diff
changeset
|
45 | perform action "AXRaise" of window newterm |
7520062c1461
okay -actually- get it to focus the new window
Meredith Howard <mhoward@roomag.org>
parents:
648
diff
changeset
|
46 | end tell |
495
31fc84fa156c
Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents:
493
diff
changeset
|
47 | end tell |
31fc84fa156c
Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents:
493
diff
changeset
|
48 | ]]) |
31fc84fa156c
Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents:
493
diff
changeset
|
49 | end) |
31fc84fa156c
Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents:
493
diff
changeset
|
50 | |
734
294238afafac
Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents:
733
diff
changeset
|
51 | cmdShift('return', function () |
294238afafac
Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents:
733
diff
changeset
|
52 | os.execute(os.getenv('SHELL')..' -l -i -c "exec mvim"') |
294238afafac
Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents:
733
diff
changeset
|
53 | end) |
644
42383cfcb729
add cmd-shift-return for quick mvim windows
Meredith Howard <mhoward@roomag.org>
parents:
620
diff
changeset
|
54 | |
500
efce0f59ef14
Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents:
495
diff
changeset
|
55 | -- cache window frames before moving? |
efce0f59ef14
Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents:
495
diff
changeset
|
56 | -- save cache? |
efce0f59ef14
Fix terminal shortcut when iterm not running yet
Meredith Howard <mhoward@roomag.org>
parents:
495
diff
changeset
|
57 | -- 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
|
58 |