.hammerspoon/init.lua

Sat, 15 Apr 2023 01:27:25 -0500

author
Meredith Howard <mhoward@roomag.org>
date
Sat, 15 Apr 2023 01:27:25 -0500
changeset 1105
f2deab330bf1
parent 1072
68ed15b14844
permissions
-rw-r--r--

Switch vimwiki to SynologyDrive

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 ()
1072
68ed15b14844 Switch shortcut to launch goneovim
Meredith Howard <mhoward@roomag.org>
parents: 987
diff changeset
51 local a = findOrLaunch('iTerm2')
908
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 ()
1072
68ed15b14844 Switch shortcut to launch goneovim
Meredith Howard <mhoward@roomag.org>
parents: 987
diff changeset
57 os.execute(os.getenv('SHELL')..' -l -i -c "goneovim &>/dev/null &"')
734
294238afafac Actually... hs.execute blocks everything
Meredith Howard <mhoward@roomag.org>
parents: 733
diff changeset
58 end)

mercurial