Skip to content

Instantly share code, notes, and snippets.

@mattpotts
Last active Jul 23, 2021
Embed
What would you like to do?
New macOS Setup

Old machine

  • Backup alfred preferences: cp '/Users/matt/Library/Application Support/Alfred/Alfred.alfredpreferences/preferences/features/websearch/prefs.plist' config:/alfred/websearch-prefs.plist
  • Backup iterm preferences (Profile, keymap, colors)
  • TODO roll all this into a script

SSH

Generate new key(s)

ssh-keygen -t rsa -b 4096 -C "$(whoami)@$(hostname)"
ssh-keygen -o -a 100 -t ed25519 -C "$(whoami)@$(hostname)"

Store passphrase in agent

Put this at the top of ~/.ssh/config

Host *
  # For macOS agent
  IgnoreUnknown UseKeychain
  UseKeychain yes
  AddKeysToAgent yes
  
  # General purpose
  ServerAliveInterval 60
  TCPKeepAlive yes

Homebrew

Install homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install applications

# General purpose
brew cask install firefox
brew cask install iterm2
brew cask install keepassxc
brew cask install alfred
brew cask install dropbox
brew cask install spectacle
brew cask install flux
brew cask install spotify
brew cask install google-chrome
brew install restic
brew cask install authy
brew install joplin (terminal)  # Not using this yet
brew cask install joplin (gui)  # Not using this yet

# Development
brew install bash
brew cask install docker
brew install git
brew install coreutils
brew install gnu-sed
brew install thefuck
brew cask install cyberduck
brew install the_silver_searcher

# Audio
brew cask install soundflower # Needs kernel permissions

Mac App Store

brew install mas
mas install $(mas search amphetamine | head -n 1 | awk '{print $1}')
mas install $(mas search todoist | head -n 1 | awk '{print $1}')
mas install $(mas search 'grand perspective' | head -n 1 | awk '{print $1}')
mas install $(mas search trello | head -n 1 | awk '{print $1}')

Manual installs

  1. Keybase - https://keybase.io/docs/the_app/install_macos

  2. Aerial Screensaver - https://github.com/JohnCoates/Aerial/releases/latest

  3. Krypton CLI - brew install kryptco/tap/kr

  4. Krypton Firefox Extension - https://addons.mozilla.org/en-US/firefox/addon/krypton-authenticator/

Terminal

Aliases

# General purpose
alias home='cd /Users/matt'
alias cal9='cal -A4 -B4'
alias cal27='cal -A13 -B13'
alias cpwd='pwd | tr -d "\n" | pbcopy'
alias cpip='wanip | tr -d "\n" | pbcopy'
alias wanip='dig +short myip.opendns.com @resolver1.opendns.com'
alias weather='curl -s wttr.in | grep -v feature | grep -v igor_chubin'
alias la='ls -lA'
alias ls='ls -G'

# macOS
alias delete_ds_store='find . -name '\''.DS_Store'\'' -type f -delete'
alias find_ds_store='find . -name '\''.DS_Store'\'' -type f'
alias finder='open .'

# Development
alias gctc='gradle clean test checkstyleall'
alias gctci='gradle clean test checkstyleall integrationtest checkstyleintegrationtest'
alias shebang='echo '\''#!/usr/bin/env bash'\'''

# Privacy
alias hosts_adblock='sudo rm -f /etc/hosts; sudo cp /etc/hosts_adblock /etc/hosts'
alias hosts_simple='sudo rm -f /etc/hosts; sudo cp /etc/hosts_simple /etc/hosts'

Functions

# What branches do I have that origin doesn't?
git_branches_not_on_origin() {
    git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}'
}

# cd to deepest directory of an absolute file path # https://unix.stackexchange.com/a/403108/15070
cdfile() {
    cd -- "$(dirname $1)";
}

cdmktemp() {
    cd $(mktemp -d)
}

# make a directory and cd to it # http://unix.stackexchange.com/a/6828/15070
mcd() {
    test -d "$1" || mkdir "$1" && cd "$1"
}

# octal permissions on ls
lso() {
  ls -l "$@" | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print}';
}

# sha256sum # https://github.com/ESGF/esg-search/issues/84
sha256sum() {
  openssl sha256 "$@" | awk '{print $2}';
}

# Recursively get absolute paths for all files and directories in a given directory
fulltree() {
  ls -R "$1" | awk '/:$/&&f{s=$0;f=0}/:$/&&!f{sub(/:$/,"");s=$0;f=1;next}NF&&f{ print s"/"$0 }'
}

# Bash history
HISTSIZE=100000
HISTFILESIZE=100000000
HISTIGNORE=ignorespace

System Preferences

These can apparently be done (mostly? completely?) via command line executables/scripts:

Trackpad

  1. Invert trackpad scrolling
  2. Turn on three-finger drag (accessibility)
  3. Turn on silent clicking
  4. Turn on tap-to-click

Sharing

  1. Pick a name for the machine

Keyboard

  1. Tick show keyboard and emoji viewer in menu bar
  2. Use F1, F2, etc. keys as standard function keys
  3. Key repeat: Maximum speed
  4. Delay until repeat: Second shortest

Application Preferences

.profile

  • Get from back-up

Finder

  • Add home folder to favourites
  • Use home folder as default Finder location
  • Show all filename extensions
  • Keep folders on top in windows when sorting by name
  • Keep folders on top on desktop
  • View -> Show Status Bar

Alfred

  • Import web shortcuts from backup ???

iTerm

  • Import preferences from config:/iterm
  • Import keymap from config:/iterm

Terminal

  • Preferences -> Profiles -> Shell -> When the shell exits -> Close the window

Messsages

  • Keep messages for one year
  • Untick being reachable on email address
  • Untick read receipts

KeePassXC

  • Tick lock database when session locked or lid closed
  • Tick hide the entry preview panel

Spectacle

  • Remove 'Center' shortcut (it's too useful elsewhere)

Bitbar

  • Set up (it's in code/github/something)

Restic

  • System Preferences -> Security & Privacy -> Full Disk Access -> Add iTerm (needed to write into ~/Pictures/Photos Library.photolibrary)
  • Restore everything from NAS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment