Skip to main content

Disable automatic macOS sleep

Sleeping on macOS messes up Thunderbolt USB devices, so I just can't have it happening.

sudo pmset -a sleep 0

For good measure, also enable "Prevent automatic sleeping when the display is off" under System Settings > Energy

Show/hide macOS Dock faster

To show the macOS app switcher on all screens:

defaults write com.apple.dock autohide-delay -int 0
defaults write com.apple.dock autohide-time-modifier -float 0.1

To see the change, restart the Dock with killall Dock.

Show macOS app switcher on all screens

To show the macOS app switcher on all screens:

defaults write com.apple.dock appswitcher-all-displays -bool true

To see the change, restart the Dock with killall Dock.

Don't use --prefer-offline

If you set --prefer-offline to true in npm, naively thinking (like I did) that this will speed up your npm installs, you will be disappointed (like I was). Annoyingly, this setting causes npm to also cache which packages and versions don't exist. Thus, updating a dependency to a newly published version causes npm to think it doesn't exist and, instead of doing anything about it, npm will simply error out.

Setup and Use Git Worktree

Clone a repo with worktrees setup from the start:

mkdir <repo-name>
cd <repo-name>
git clone --bare --filter=blob:none <git-url>
cd <repo-name>.git

Some options to help your sanity:

# always prune on fetch
git config fetch.prune true
# allow `git fetch origin <branch-name>` to work as expected (create a remote ref)
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

To create a new branch:

git worktree add ../<branch-name>
cd ../<branch-name>

To copy a remote branch (note that this will only work with the above fetch config set):

git fetch origin <branch-name>
git worktree add ../<branch-name>
cd ../<branch-name>

To create a new branch based on a remote branch:

git worktree add ../<branch-name> -b <branch-name> --no-track origin/dev
cd ../<branch-name>

Enable up-arrow history auto-complete

This how to enable up/down arrow auto-complete navigation instead of basic history navigation, without installing plugins.

Bash

nano ~/.inputrc

Paste in:

"\e[A": history-search-backward
"\e[B": history-search-forward

Run:

bind -f ~/.inputrc

Zsh

Put the following into your ~/.zshrc:

autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '^[[A' up-line-or-beginning-search # Up arrow
bindkey '^[[B' down-line-or-beginning-search # Down arrow