How I use MacOS

Update 201806

  • You will hit ulimit limits very quickly so checkout the workaround to increase the defaults here https://blog.dekstroza.io/ulimit-shenanigans-on-osx-el-capitan/

TL;DR

  • Use Hammerspoon for shortcut keys and launch terminals
  • Use Spotlight to launch anything else
  • Use BetterTouchTool for window management
  • Use numbered backgrounds to ease desktop navigation
  • Use builtin Terminal
  • Increase repeat rate

MacOS has a few terrific features I love. The flawless bluetooth support, spotlight, the quick region screenshot keystroke and the solid airplay features are all fantastic. Mac has a feeling similar to Linux, but it is not as versatile. My first days working on MacOS in late 2016 were a painful experience because Mac lacks personalization and doesn’t adapt well to my workflow.

In Mac you need to use the mouse all the time, you cannot launch more than one terminal instance, and there is no way to organize a large collection of desktops and windows. There is no way to set autofocus (focus follows the mouse and doesn’t raise windows). You need to learn to live with MacOS limitations and find hacks and workarounds to make your life as comfy as it is on Linux.

These are my recommendations:

Use Hammerspoon

After some time suffering MacOS defaults, I got to understand why Tmux is so popular in between MacOS powerusers. Terminal multiplexers get very useful when the OS offers a miserable CLI experience.

For example lets check out what MacOS does when you try to open multiple instances of a terminal:

  • Open a terminal using the Finder or the Dock or a Launcher
  • Try to open another.
  • Mac detects there is another instance and changes the focus to it instead of opening a new one.

I understand why most people may find this behavior useful, but this is just not compatible with my workflow. I like to use a lot of virtual desktops, with hordes of terminals open at the same time.

In Mac I use Hammerspoon as an xbindkeys replacement, mainly to for shortcuts to open new terminals at any place and time.

This is my configuration

-- Modifier shortcuts
local cmd_ctrl = {"ctrl", "cmd"}

hs.hotkey.bind(cmd_ctrl, "A", function()
  hs.alert.show("Opening Alacritty using Lua")
  os.execute("open -nF /Applications/Alacritty.app")
end)

hs.hotkey.bind(cmd_ctrl, "T", function()
  hs.alert.show("Opening iTerm2 using Lua")
  os.execute("open -nF /Applications/iTerm.app")
end)

hs.hotkey.bind(cmd_ctrl, "M", function()
  hs.alert.show("Maximizing application")
  f = hs.window.focusedWindow()
  f:maximize()
end)

hs.hotkey.bind(cmd_ctrl, "B", function()
  hs.alert.show("Going to next song on CMUS")
  os.execute("/usr/local/bin/cmus-remote -n")
end)

hs.hotkey.bind(cmd_ctrl, "Z", function()
  hs.alert.show("Going to previous song on CMUS")
  os.execute("/usr/local/bin/cmus-remote -r")
end)

Use numbered wallpapers instead of meta-tab / mission control

MacOS wants you to use meta-tab or mission control to switch windows. This is effective only if you open only a few apps simultaneously. It doesn’t work for me. I organize my work by vrtual desktops and instead of alt-tabbing applications I quick switch virtual desktops.

As MacOS doesn’t display the active desktop when you switch, I resorted to numbered backgrounds to help me navigate. This works because MacOS window compositor paints first the desktop background, and afterwards paints the windows on top. Therefore the desktop id is rendered for a split second, enough time to know where you ended up - You may need to disable the animations.

If you use multiple displays, you need to keep first desktop on each display unused. MACOS unifies the windows of this first desktop when the monitor is detached. This is a very nasty feature deeply hardcoded on the UI that cannot be disabled. By leaving empty the first desktop of each screen, when they are unified, you will end up with an empty virtual desktop on the laptop and your windows will not be messed up.

You can download my numbered wallpaper set here: Numbered backgrounds

Use an App launcher to launch programs

Make the dock as small as possible and hide it. Finder, MacOS file manager is equally annoying because it hides system files and makes file system navigation a chore. Try Marta instead.

I find Spotlight very useful and comes out-of-the-box. If you have CPU and RAM to spare you may enjoy Cerebro as it is very configurable. Cerebro is an open sourced Alfred clone for Windows, MacOS and Linux.

Remove noise by forcing apps to dissapear from the dock. It will also remove them from the alt-tab menu. You don’t want to alt-tab 30 terminal windows. This hack works for any app:

/usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" /Applications/(APP)/Contents/Info.plist

Use BetterTouchTool for window management

I spent most of the time on the terminal, therefore I love tiling window managers. In Mac I tried a tiling window manager Amethyst for a few months. It was a mess because you can see how Amethyst fights against Quartz compositor all the time.

I truly tried everything I could find, and eventually I discover BetterTouchTool and didn’t look back. It is not as flexible as I would like, and I don’t use it for what it was originally developed, but it works great and completes MacOS window management missing features (window snapping, window auto sizing etc).

Use the default Terminal.app

I tested all terminal emulators.

  • Iterm2: Nice features, slow rendering.
  • Hyper: Very nice features, very slow rendering.
  • Kitty: Copy paste doesn’t work in Mac.
  • Alacritty: It lacks scroll.

Builtin Terminal.app launches fast, renders fast and has all the features I need.

Increase keystroke repeat rate

It is painfully slow by default and there is no way to make it fast enough on the UI:

defaults write -g InitialKeyRepeat -int 10 # normal minimum is 15 (225 ms)
defaults write -g KeyRepeat -int 1 # normal minimum is 2 (30 ms)