git clone https://github.com/agzam/spacehammer ~/.hammerspoon
I love Vim keybindings and I needed to find a better, more efficient way to manage windows and jump between the apps.
Ideally I wanted to stay in the home row and control as much as I can with
h/j/k/l keys. Adding tens (possibly hundreds) of key-combo shortcuts for every single desirable action is not a good solution.
Also, unlike in vanilla Vim - a single modal (to switch from Normal to Edit to Select mode) is often not enough. So I’ve taken approach inspired by Spacemacs. In Spacemacs - there is a single main modifier key - SPACE. Of course I couldn’t just use SPACE - because none of the modern operating systems can infer current mode of the operation - either user is typing or if cursor focused on an input field. So I have to use a key-combo.
Hammerspoon is incredibly powerful tool, and it has allowed me to take my workflow to a completely different level. Jumping between apps, controlling windows, searching things, etc. become so much easier - everything follows simple semantics of keeping your fingers on the home row. And no need to memorize myriad of keystrokes. Or to drag your hand to reach for mouse/touchpad/arrow keys - that just slows you down.
Main key combo is set to
Cmd SPC. By default, in OS X it’s used for something else (usually for Spotlight).
You’re gonna need to rebind that key combination!
Go to your Preferences/Keyboard, find associated keybinding and change it. Unfortunately, simply disabling it is NOT enough. You have to set it to be something else e.g.
Ctrl+Cmd+Shift+\ or whatever (I dunno - use your imagination), it doesn’t really matter, since you can then uncheck the checkbox. If you find that
Cmd SPC ain’t very convenient for you - simply modify
~/.hammerspoon/init.lua and set it to whatever keybinding you like.
Cmd SPC w - Window management
hjkl- moving windows around halves of the screen
Ctrl + hjkl- for jumping between application windows (handy for side by side windows)
w- jump to previous window
n/p- moving current window to prev/next monitor
Alt + hjkl- moving in increments (works across monitors)
Shift + hjkl- re-sizing active window
g- re-sizing with hs.grid
m- maximize active window
u- undo last window operation (similar to Spacemacs’s
SPC w u)
Cmd SPC a - Apps (quick jump)
you can add more, also try
Cmd SPC j j
Cmd SPC SPC - open Alfred search bar
SPC anytime in any modal takes you to Alfred search popup
Cmd SPC m - multimedia controls
Why just not use media-keys?
a) because different external keyboards impose their own ways to control media.
b) I’d like to keep fingers on the home row
it’s configured to work with Google Play Music Desktop App. If you want it to be Spotify or anything else - change the value of
Alternative App Switcher
Simple tab switcher for Chrome and iTerm
Cmd l in Chrome re-mapped to
Alt h/j/k/l- simple left/right/up/down
Alt+Shift h/j/k/l- word wise left/right/up/down
Alt+Ctrl+Shift h/j/k/l- selecting things
These can be disabled in certain apps (by default they they are ignored in Emacs)
Slack Desktop Client enhancements
- Switching to Slack via “Apps” modal
CMD+SPC a s- automatically opens Slack’s “Jump to” dialog
- Scrolling current Slack thread with
- Jumping to the end of the thread with
- Adding emoji to the last message -
C-r(sorry, but default
Cmd-Shift+\is horribly inconvenient)
C-o/C-i- jumping back and forth in history
j/k- to scroll
n/p- page up/down
Ctrl-o/i- to go to previous/next item
- [ ]
fdto exit modals (like
- [ ] window configuration profiles (similar to Layouts feature in Spacemacs)
Cmd SPC Tabto switch to previous window This is now done, it’s bound to
CMD+Spc+w- similar to Spacemacs’s
SPC w w
- [X] better module organization - so modals can be added without much hassle
- [ ] Disable non-available keys in a modal. Keys that not listed should be simply ignored see #1
- [ ] I’d like to find a way to jump to Chrome window with specific profile (right now
Ctrl-Cmd SPC a cwill switch to Chrome, but if you have multiple profiles you have to manually find the one you need)
- [ ] Another thing I want is to be able to toggle ChromeDevtools panel - this is somewhat tricky, see this issue
- [ ] Better than default HUD display (something less obtrusive than
hs.alertwould be nice
This is quite straightforward. Lua is extremely simple language. I shamelessly borrowed this state-machine implementation, and that makes adding new modes and extending current ones a piece of cake.