.hammerspoon/init.lua

Fri, 05 Aug 2022 20:56:17 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Fri, 05 Aug 2022 20:56:17 -0500
changeset 997
9e1ec7624f59
parent 987
556f618e117a
child 1072
68ed15b14844
permissions
-rw-r--r--

Update for newer configs, use autostash

987
556f618e117a launch stuff from home
Meredith Howard <mhoward@roomag.org>
parents: 908
diff changeset
1 hs.fs.chdir(os.getenv("HOME"))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 hs.window.animationDuration = 0
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
4 -- aliases and partial bindings to make life easier
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 local bindKey = hs.hotkey.bind
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 local cmd = hs.fnutils.partial(bindKey, {"cmd"})
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7 local cmdShift = hs.fnutils.partial(bindKey, {"cmd", "shift"})
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
8 local cmdCtrl = hs.fnutils.partial(bindKey, {"cmd", "ctrl"})
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
10 function focusedWindow()
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
11 return hs.window.focusedWindow() or hs.window.desktop()
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
12 end
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
13
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
14 function focusTo(direction)
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
15 local fn = hs.getObjectMetatable('hs.window')['focusWindow' .. direction]
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
16 return function ()
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
17 fn(focusedWindow(), nil, nil, true)
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
18 end
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
19 end
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20
908
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
21 function findOrLaunch(a)
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
22 return hs.application.find(a) or hs.application.open(a, 3)
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
23 end
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
24
620
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
25 -- and the key bindings
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
26 cmdShift('r', hs.reload)
ce78d743489f housekeeping
Meredith Howard <mhoward@roomag.org>
parents: 520
diff changeset
27
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
28 cmd('k', focusTo('North'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
29 cmd('up', focusTo('North'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
31 cmd('j', focusTo('South'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
32 cmd('down', focusTo('South'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
34 cmd('h', focusTo('West'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
35 cmd('left', focusTo('West'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36
907
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
37 cmd('l', focusTo('East'))
df71b104b773 Fix up focus-to shortcuts for new hammerspoon
Meredith Howard <mhoward@roomag.org>
parents: 906
diff changeset
38 cmd('right', focusTo('East'))
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
40 cmdShift('up', function () focusedWindow():maximize() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
41
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
42 cmdShift('down', function () focusedWindow():minimize() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
43
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
44 cmdShift('left', function () focusedWindow():moveToUnit(hs.layout.left50) end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
45 cmdShift('right', function () focusedWindow():moveToUnit(hs.layout.right50) end)
493
165f65e47a3c Start a hammerspoon config!
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
46
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
47 cmdCtrl('left', function () focusedWindow():moveOneScreenWest() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
48 cmdCtrl('right', function () focusedWindow():moveOneScreenEast() end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
49
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
50 cmd('return', function ()
908
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
51 local a = findOrLaunch('iTerm')
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
52 a:selectMenuItem({"Shell", "New Window"})
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
53 a:activate()
495
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
54 end)
31fc84fa156c Fill in some more hotkeys
Meredith Howard <mhoward@roomag.org>
parents: 493
diff changeset
55
734
294238afafac Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents: 733
diff changeset
56 cmdShift('return', function ()
294238afafac Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents: 733
diff changeset
57 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
58 end)
644
42383cfcb729 add cmd-shift-return for quick mvim windows
Meredith Howard <mhoward@roomag.org>
parents: 620
diff changeset
59
908
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
60 cmdCtrl('return', function ()
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
61 local a = findOrLaunch('MacVim')
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
62 a:selectMenuItem({"File", "New Window"})
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
63 a:activate()
fa7c0607c00e Simpler new-window short impls
Meredith Howard <mhoward@roomag.org>
parents: 907
diff changeset
64 end)

mercurial