Skip to content

Instantly share code, notes, and snippets.

@mieky
Last active December 2, 2023 21:10
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mieky/b5c11a607708f83de101b0c108fc929e to your computer and use it in GitHub Desktop.
Save mieky/b5c11a607708f83de101b0c108fc929e to your computer and use it in GitHub Desktop.
MacOS Lifehacks

Collection of useful tips & tricks to set up on a Mac.

Safari: bind cmd+alt+arrows to switch between previous/next tab

defaults write -app Safari NSUserKeyEquivalents '{
"Show Next Tab" = "@~\\U2192";
"Show Previous Tab" = "@~\\U2190";
}'

Save & restore keyboard shortcuts

List current keyboard shortcuts:

defaults find NSUserKeyEquivalents

https://superuser.com/questions/670584/how-can-i-migrate-all-keyboard-shortcuts-from-one-mac-to-another

Screenshot location

Write screenshots to a folder in iCloud Drive, instead of the desktop.

mkdir -p $HOME/Library/Mobile\ Documents/com~apple~CloudDocs/Screenshots
defaults write com.apple.screencapture location $HOME/Library/Mobile\ Documents/com~apple~CloudDocs/Screenshots

These are some (commercial) applications and utilities that make life better.

Utility/helper

Moom ($20)

Great for Windows-like window interaction: drag on the edge of the screen to resize, or define keyboard shortcuts for pre-defined window sizes and positions. Really, really good when you get used to it.

BetterTouchTool

Allows you to bind basically any keyboard + mouse combos. Good in combination with Apple's Mighty Mouse, where you might e.g. bind a three-finger swipe to change between tabs in your web browser / code editor.

CommandQ

Prevent applications from closing by accidentally pressing command+Q.

Allows redirecting your play/pause buttons to e.g. Spotify and prevent the current web page/iTunes from stealing them.

Alfred

A launcher like Spotlight, but with many neat customization options. Free, but with the ~10€ Powerpack you get lots more.

Office

Fantastical

A costly calendar app for Mac & iOS, but totally worth it. Works with most types of servers one might use, and allows you to schedule new events effortlessly with keyboard shortcuts + parsing the event dates and locations from your input.

General

1Password

The definite password manager. Buy the subscription and got all your devices covered at once. Integrates with all major web browsers on the desktop, and integrates fantastically with Safari on iOS. Also handles one-time passwords, so you can skip Google Authenticator for good.

RescueTime

Sits in the background and tracks your time usage, giving you reports on where your time went. You can further define "productive" and "unproductive" apps or sites.

Todoist

My go-to todo app. It's not perfect, but still simple and good enough for me to pay a yearly subscription for it.

Recommended apps

iTerm2

Like Terminal.app, but with a bit more customization options.

The missing macOS package manager. Makes installing most shell apps a breeze.

zsh + prezto

zsh is quite a lot more versatile than bash, and Prezto makes setting up and using zsh much nicer. It comes with a number of very nice bundled helpers, such as auto-complete for various git & node commands and a very handy command history search.

Shell utilities

autojump

Effortlessly jump to any directory you've visited (by their frequency). For example, j cool might take you to ~/dev/services/my-cool-service.

brew install autojump

bat

A cat replacement with colors & niceties.

brew install bat

In ~/.config/bat/config:

--theme="TwoDark"
--style="numbers,changes,header"

For getting bat into muscle memory, it might be useful to alias it over cat:

echo "alias cat='bat -p'" >>~/.aliases # sourced in ~/.zshrc

diff-so-fancy

More readable, colorful diffs:

https://github.com/so-fancy/diff-so-fancy

brew install diff-so-fancy

mackup, for migrating dotfiles & app configuration

Save & restore many of your dotfiles & application configurations with mackup:

https://github.com/lra/mackup/blob/master/doc/README.md

You can use iCloud Drive (or Dropbox, etc.) as the storage engine. In your ~/.mackup.cfg:

[storage]
engine = icloud

This will store the configuration into /Library/Mobile Documents/com~apple~CloudDocs/Mackup:

  • Save current configuration with mackup save
  • When restoring on another computer with iCloud Drive installed, put this configuration in place and do a mackup restore

scmpuff

A must-have for any command-line Git user. Provides short numeric shortcuts for changed file names, so you can easily reference files in your git operations. (scmpuff is basically a simplified and more robust single-file binary version of scm-breeze)

https://github.com/mroth/scmpuff

These are some nice aliases for MacOS. It's a good idea to put them e.g. in your ~/.aliases and have them sourced by your shell.

Find files by their name inside this directory and its children, e.g. "f my-component"

f='find . | grep '

Start a web server in this directory:

server='python -m SimpleHTTPServer'

What's the weather like in Tampere?

sää='curl -4 wttr.in/Tampere'

Which apps are running on which ports:

ports='sudo lsof -iTCP -sTCP:LISTEN -n -P'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment