Coder Social home page Coder Social logo

spacehammer's Introduction

Hammerspoon config inspired by Spacemacs

git clone https://github.com/agzam/spacehammer ~/.hammerspoon

Rationale

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.

Important note!

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.

Features

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)

  • e - Emacs
  • g - Chrome
  • i - iTerm
  • s - Slack
  • b - Brave

you can add more, also try Cmd SPC j j

Cmd SPC SPC - open Alfred search bar

basically pressing 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 musicApp in multimedia.lua module

Other features

Alternative App Switcher Cmd j/k

Simple tab switcher for Chrome and iTerm Cmd h/l

Cmd l in Chrome re-mapped to Cmd+Shift l

Simple vi-mode

  • 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 C-j/C-k or C-e/C-y
  • Jumping to the end of the thread with C-g
  • 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

Preview app

  • j/k - to scroll
  • n/p - page up/down
  • Ctrl-o/i - to go to previous/next item

  • [ ] jk or fd to exit modals (like evil-escape-key-sequence in Emacs)
  • [ ] window configuration profiles (similar to Layouts feature in Spacemacs)
  • [X] Cmd SPC Tab to 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 c will 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.alert would be nice

Customizing

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.

If you have any questions, please don’t hesitate to ask. If you feel uncomfortable about posting an issue - you can find me in Spacemacs’s Gitter channel, or on Clojurians Slack

spacehammer's People

Contributors

agzam avatar

Watchers

Thomas B Homburg avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.