Setting Up a Mac in 2022
Tags: mac, setup
Published: 2022-01-08 07:17:58

## System Preferences

- Disable "Natural" Mouse Scoll Direction
  - System Preferences > Mouse > Uncheck Scroll Direction: Natural
- Use function keys without fn key
  - System Preferences > Keyboard > Check Use F1, F2 etc. keys as standard function keys
- Remove text replacements
  - System Preferences > Keyboard > Text > Remove “omw”, Uncheck everything on the right
- Remove all items from dock
  - Right-click app icon > Options > Uncheck keep on dock
- Hide dock
  - Right-click on empty space on the dock > turn hiding on
- Show file extensions
  - Open finder (open any directory) > cmd + , to open settings > advanced tab > check show all filename extensions

## Homebrew (Package Manager)

- follow instructions on brew's [home page](https://brew.sh/)
  - run the following in the terminal:
    -  `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`

## Install and Replace Default Applications

- Section TL;DR
```zsh
brew install alfred iterm2 brave-browser visual-studio-code
```

### Replace Spotlight Search with Alfred 4

> Alfred is an ... app which boosts your efficiency ...

- Install [Alfred 4](https://www.alfredapp.com/)
    - `brew install alfred`
- Change Spotlight's default hotkeys
  - Open Spotlight
    - default: cmd + space
  - Open Spotlight-specific preferences
    - cmd + ,
  - Go to shortcuts page
    - click Keyboard Shortcuts...
  - Change shortcuts for "Show Spotlight Search" or disable it (I use cmd + shift + space)
- Setup Alfred
  - Open Alfred
    - type alfred in spotlight search
  - Go through setup, give it appropriate permissions
  - Change Alfred hotkey to cmd + space
    - in alfred, hit cmd + , to open settings
    - in general tab, click on Alfred Hotkey:
  - Add Downloads directory to config
    - in Alfred, go to Features tab
    - in Search Scope, click the + button near the bottom-right

### Replace Terminal with iTerm2

- Install iTerm2
  - `brew install iterm2`
  - iterm2 > preferences (cmd + ,) > keys > Check show/hide all windows with a system-wide hotkey


### Replace Safari with Brave

- `brew install brave-browser`

### Replace TextEdit with Visual Studio Code

- `brew install visual-studio-code`

## Terminal Setup

- remove last login message
  -  `touch ~/.hushlogin`
- replace default zsh
  - `brew install zsh`
- install zsh theme manager ([oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh))
  - `sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)”`
- remove default theme
  - comment this (line 5): `# ZSH_THEME="robbyrussell”`
- install theme ([powerlevel10k](https://github.com/romkatv/powerlevel10k))
  - `brew install romkatv/powerlevel10k/powerlevel10k`
- apply theme
  - append to bottom: `source /usr/local/opt/powerlevel10k/powerlevel10k.zsh-theme`
- restart terminal (IMPORTANT)
- powerlevel10k should take you through its wizard, and install a powerline font (MesloLGS NF)
- apply new font to iTerm
  - open iTerm (cmd + space, if following previous setup)
  - open settings (cmd + ,)
  - profile > text > font > click change font ... > select MesloLGS NF
- apply new font to Visual Studio Code
  - open Visual Studio Code
  - open settings (cmd + ,)
  - scroll to font and type MesloLGS NF
- Setup zsh autocompletions, syntax highlighting
    - `brew install zsh-autosuggestions`
    - `brew install zsh-syntax-highlighting`
    - add to bottom of zshrc
        - `source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh`
        - `source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh`
    - configure suggestion strategy (append anywhere on zshrc)
        - `ZSH_AUTOSUGGEST_STRATEGY=(completion history)`

## Misc

### Git

- `brew install git`
- create ssh key (https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)
    - `ssh-keygen -t ed25519 -C "your_email@example.com"`
- `ssh-add ~/.ssh/id_ed25519`
- enable zsh plugin for ssh-agent
  - add `ssh-agent` between round brackets where plugins are defined
    - e.g. `plugins=(git ssh-agent)`

### node / nvm

fast version manager (alternative to nvm)

- Install
  - `brew install fnm`
- Make avaialable to zsh
  - append to zshrc: `eval "$(fnm env)"` 
- Show available node versions
  - `fnm list-remote`
- Install a node version
  - `fnm install <node-version>`
- Make a version of node the default
  - `fnm default <node-version>`
- Check if node was install correctly
  - `node --version`