/setup-macos

Personal setup for a new macOS install.

Primary LanguageShell

setup-macos

Personal setup for a new macOS install.

Table of Contents

Install the Xcode Command Line Tools

$ xcode-select -p # Check if the full Xcode package is already installed
$ xcode-select --install # Install Xcode Command Line Tools

Install Homebrew

Website: https://brew.sh

$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install and set up Zsh

More information on this wiki page from Oh-My-Zsh and this gist.

Check if zsh is already installed

$ zsh --version # If installed, should be zsh 5.0 or more recent
$ echo $SHELL # Expected result should be /usr/bin/zsh or /bin/zsh

Install zsh and make it the default shell

$ brew install zsh zsh-completions zsh-autosuggestions # Install zsh
$ zsh --version # Should be zsh 5.0 or more recent
$ chsh -s $(which zsh) # Make zsh the default shell
$ echo $SHELL # Expected result should be usr/bin/zsh or /bin/zsh

Install Oh-My-Zsh

$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Set personal custom theme & prompt

$ curl https://gist.githubusercontent.com/imkh/db581924555a3a69f6be658a4c42d7bb/raw/d38d501bd9c9e60299d8fd96ac075873a8eacf44/refined-imkh --create-dirs -o $ZSH_CUSTOM/themes/refined-imkh.zsh-theme

And in ~/.zshrc:

ZSH_THEME="refined-imkh"

Add syntax highlighting

$ brew install zsh-syntax-highlighting

And add this to the end of the ~/.zshrc file:

# Add to end of the ~/.zshrc file
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Set window & tab title to current directory

In the .zshrc file:

DISABLE_AUTO_TITLE="true"

function precmd () {
  # window_title="\033]0;${PWD##*/}\007"
  if [[ -n $SSH_CONNECTION ]]; then
    window_title="\033]0;${USER}@${HOSTNAME%%.*}: ${PWD/#$HOME/~}\007"
  else
    window_title="\033]0;${PWD/#$HOME/~}\007"
  fi
  echo -ne "$window_title"
}

More information here:

Install GNU ls for better ls colors

GNU dircolors allows to use different colors theme when typing ls in the terminal. More information here (make sure to read the quick note for macOS).

$ brew install coreutils

And add this alias in the ~/.zshrc file:

alias ls="gls --color=auto"

Install Emacs

$ brew install emacs

Install Go

$ brew install go

Install Node.js and npm

$ brew install node

Install MySQL

$ brew install mysql # Install MySQL
$ brew services list # List the Homebrew services
$ brew services start mysql # Start the MySQL service
$ mysql -uroot -p # Start a MySQL shell
$ mysqladmin -u root password 'yourpassword' # Change root password

Install PostgreSQL

Official guide: https://wiki.postgresql.org/wiki/Homebrew

$ brew install postgresql # Install PostgreSQL
$ brew services list # List the Homebrew services
$ brew services start postgresql # Start the PostgreSQL service
$ psql postgres # Start a PostgreSQL shell

Install MongoDB

Official guide: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

$ brew tap mongodb/brew
$ brew install mongodb-community@5.0 # Install MongoDB
$ brew services list # List the Homebrew services
$ brew services start mongodb-community@5.0 # Start the MongoDB service
$ mongosh # Start a MongoDB shell

Apps

Essential Apps

Name Description Paid? Settings
1Password Password manager. 💰
Google Chrome Web browser.
Slack Team communication app.
Signal Private messaging app.
Spotify Spotify desktop app.
LyricsX Synced lyrics app.
MusicHarbor New music release tracker. 💰
Magnet Window manager. 💰
Moom Windows layout manager. 💰
Wipr Ad & tracker blocker for Safari. 💰
Amphetamine Keep-awake app.
Paste Cloud clipboard history & snippets manager. 💰

Development Tools

Name Description Paid? Settings
Tower Git desktop client. 💰
Kaleidoscope File comparison app (diff tool). 💰
Paw Full-featured HTTP client for API development (similar to Postman). 💰
iTerm2 Terminal emulator for macOS. Yes
Visual Studio Code Source code editor. Yes
Xcode Official IDE for macOS, iOS, watchOS, and tvOS development.
Android Studio Official IDE for Android development.
Docker Create, deploy, and run applications by using containers.
Sequel Pro MySQL database management tool. 💰
Postico PostgreSQL database management tool. 💰
Robo 3T MongoDB database management tool.
DB Browser for SQLite SQLite database management tool.
Red Redis database management tool.
Proxyman Web Debugging Proxy app. 💰

Useful Apps

Name Description Paid? Settings
Pixelmator Pro Professional image editing tool. 💰
Parallels Mac & Windows virtualization. 💰
IINA Multimedia player.
Discord Voice & text chat app for gaming communities.
Reflector Android & iOS wireless screen mirroring. 💰
Tuxera NTFS drives read and write support. 💰
CleanShot X GIF recording and sharing. 💰
Sip Color picker for macOS. 💰
LiveHome 3D Home and Interior Design Software 💰
Ledger Live Companion app for Ledger hardware wallet devices.
Notion The all-in-one workspace for your notes, tasks, wikis, and databases.
Meta Advanced Music Tag Editor for macOS. 💰
Cornerstone SVN client for macOS. 💰
The Archive Browser Browser for archive type files (zip, rar, 7-zip, tar, etc). 💰
Texpad LaTeX editor. 💰
Leech Lightweight download manager. 💰
Numi Beautiful calculator app. 💰
Optimage Advanced image optimization tool. 💰
SourceCodeSyntaxHighlight Quick Look extension for highlight source code files.
QLMarkdown Quick Look extension for Markdown files.
AppCleaner Applications uninstaller.

Git global configuration

gitignore

$ curl https://raw.githubusercontent.com/github/gitignore/main/Global/macOS.gitignore -o ~/.gitignore_global

gitconfig

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
$ git config --global core.editor emacs
$ git config --global core.excludesfile ~/.gitignore_global

Set up Git SSH Keys

🆕 With the new 1Password 8, we can generate & store SSH keys directly into 1Password. Follow the official guide instead of the instructions below.

Official documentation

Initial configuration

Create a SSH config file:

$ touch ~/.ssh/config

And write in it:

# GitHub.com server
Host github.com
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa

# Private Enterprise GitLab server
Host <gitlab.company.com>
 RSAAuthentication yes
 IdentityFile ~/.ssh/id_rsa_gitlab_<company_name>

Generate and add SSH keys

$ ls -al ~/.ssh # Lists the files in your .ssh directory, if they exist
$ ssh-keygen -t rsa -b 4096 -C "email@domain.com" # Generate a new SSH key
$ pbcopy < ~/.ssh/id_rsa.pub # Copies the contents of the id_rsa.pub file to your clipboard

Then paste the content of the clipboard in:

  • Settings > SSH and GPG keys > New SSH key for GitHub.
  • Settings > SSH Keys for GitLab.

Set up GPG Keys to sign commits

Official documentation

Install the GPG Suite

Download and install the GPG Suite from the official website.

Generating a GPG key

$ gpg --full-gen-key

And follow the instructions. Recommended value for RSA keys is 4096 bits long (highest value). Pick a strong password when asked and type it twice to confirm.

Add GPG keys to GitHub/GitLab account

$ gpg --list-secret-keys --keyid-format LONG <email_address>
# Copy the GPG key ID that starts with 'sec' and after 'rsa4096/'
$ gpg --armor --export <gpg_key_id> | pbcopy

Then paste the content of the clipboard in:

  • Settings > SSH and GPG keys > New GPG key for GitHub.
  • Settings > GPG Keys for GitLab.

Associating GPG keys with Git

$ gpg --list-secret-keys --keyid-format LONG <email_address>
# Copy the GPG key ID that starts with 'sec' and after 'rsa4096/'
$ cd <your_git_project> # To associate GPG keys on a project-to-project basis rather than globally
$ git config user.signingkey <gpg_key_id>
$ git config commit.gpgsign true

Configuration for Tower.app

Some helpful links:

$ git config --global gpg.program /usr/local/MacGPG2/bin/gpg2
$ echo no-tty >> ~/.gnupg/gpg.conf