- Introduction and Other Resources
- Install Developer Applications
- Configure CLI
- Common Workflows
- DANGER - DO NOT RUN THESE UNLESS YOU KNOW WHAT YOU ARE DOING
If you are not on a machine with an Apple M1 Chip be aware that there will be a few extraneous steps and commands throughout this gist. But for the most part if you ignore those commands and leave them out then mostly everything else should be fairly agnostic to Apple M1, Apple x86, or Linux.
Unfortunately, if you're on Windows you'll be hard pressed to find a single section of this gist that isn't broken or incompatible. On the bright side, that means you can write your own Useful Snippets gist for Windows users and you'll save a couple million people a few billion headaches.
Other good resources:
- Robin Wieruch's 2023 Mac Setup for Web Development
- Swyx's 2022 New Mac Setup
- Sean Washington Uses
- Everything Nexxel Installed on His New 2023 Mac
- Christoph Nakazawa Sets up a new Mac, Fast
- VS Code cause I'm too lazy to learn Vim
- Xcode Command Line Tools cause Git won't work without it
- Warp cause I like their default setup and don't want to go down the rabbit hole of terminal config
Install and Configure Homebrew
After running the install script, we'll run a handful of commands to create a .zprofile
file which will set the Homebrew path with shellenv
. I also turn off analytics with the final command but that is not a required step.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # Install Homebrew
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> $HOME/.zprofile # Create .zprofile shell startup file with command to setup a Homebrew environment
cat $HOME/.zprofile # Display contents of .zprofile
eval "$(/opt/homebrew/bin/brew shellenv)" # Setup Homebrew environment in current terminal session
brew analytics off # Turn off data collection for analytics
brew -v # Check Homebrew version
brew -h # Homebrew help command
brew config # Check Homebrew config
Install CLIs and Utility Packages with Homebrew
brew install deno ffmpeg gh httpstat pnpm railway tree webp yt-dlp jq
There are many ways to see what has been installed with Homebrew, here is a sequence of increasingly useful ways to do so:
ls /opt/homebrew/bin # List all binaries installed by Homebrew, too noisy to be useful
brew list --versions # List all installed Homebrew packages and their version number, better but still includes peer dependencies
brew deps --installed --direct # List only the direct dependencies of the installed Homebrew packages
brew deps --tree --installed --direct # List only the direct dependencies of the installed Homebrew packages but in a tree format this time
brew leaves | xargs -n1 brew desc --eval-all # List top level brew packages and descriptions, the thing you actually want to know
Install Volta and Node
curl https://get.volta.sh -s | bash # Install Volta
source .profile # Initialize Volta environment for current terminal session
volta install node@20 # Install Node 20
node -v # Verify correct version of Node has been installed
With Node v20, a server or script can be run without nodemon
or dotenv
.
node --env-file=.env --watch index.js
Install Node CLIs with Volta
volta install netlify-cli vercel wrangler yarn@1
List all tools installed with Volta:
volta list
Other ways to inspect your Volta/Node/npm packages and general locally installed binaries:
ls /$HOME/.volta/bin # List all JavaScript packages installed and managed with Volta by inspecting `.volta/bin`
npm list --location=global --depth 0 # When installing all global Node packages through Homebrew/Volta, listing globally installed npm packages contains only `corepack` and `npm`
ls /usr/local/* # View binaries installed locally through specific shell script files instead of Homebrew/VoltaList
tree /usr/local/ -L 2 # List locally installed binaries a different way
Inspect your Volta configuration file:
cat $HOME/.volta/tools/user/platform.json
Since I installed a specific legacy version of yarn
and opted not to use Volta's experimental pnpm
support (see GitHub Issue #737), this outputs the following on my machine:
{"node":{"runtime":"20.12.0","npm":null},"pnpm":null,"yarn":"1.22.22"}
Authenticate CLIs for GitHub, Railway, Netlify, Vercel, and Wrangler.
# Run `gh status` or `gh help` for more info
gh auth login
# Run `ntl status` or `ntl help` for more info
ntl login
# Run `vercel whoami` or `vercel help` for more info
vercel login
# Run `railway whoami`, `railway status`, or `railway help` for more info
railway login # or `railway login --browserless` for browserless login
# TODO: wrangler login
Set name, email, default branch, and automatic remote pushing.
git config --global init.defaultBranch main
git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "MY_NAME@example.com"
git config --global --add --bool push.autoSetupRemote true
These changes can be seen in your .gitconfig
file.
[init]
defaultBranch = main
[user]
name = FIRST_NAME LAST_NAME
email = MY_NAME@example.com
[push]
autoSetupRemote = true
Create and Push a Public GitHub Repo
mkdir github-cli-example
cd github-cli-example
echo '# GitHub CLI Example' >> README.md
git init
git add .
git commit -m "do the thing"
gh repo create github-cli-example \
--public \
--push \
--source=. \
--description="An example GitHub repo created and pushed to main with the GitHub CLI." \
--remote=upstream
Deploy PostgreSQL Database with Railway
railway init -n example
railway add -p postgresql
railway open
Create aliases in .zshrc
Add the following lines of code to .zshrc
:
alias ignore='echo ".DS_Store\nnode_modules\n.env\n.env.local" > .gitignore'
alias gs="git status"
alias gi="git init"
alias gc='git add . && git commit -m "commit"'
alias gp="git push"
alias t="tree -I node_modules -I whisper.cpp"
alias ls="ls -1"
alias ni='npm init -y && npm pkg set type="module"'
alias path='echo "$PATH" | tr ":" "\n" | nl'
ignore
aliases toecho ".DS_Store\nnode_modules\n.env\n.env.local" > .gitignore
for creating a custom.gitignore
file that ignores.DS_Store
for Mac users,node_modules
for JavaScript projects, and.env
/.env.local
for sensitive API keys.gi
aliases togit init
for initializing a Git repositorygs
aliases togit status
for checking the status of commitsgc
aliases togit add . && git commit -m "commit"
for automatically staging and committing changes (only use for solo projects where you do not wish to have meaningful commit messages to explain changes over time)gp
aliases togit push
to push all new commitst
aliases totree -I node_modules
for printing a project's directory structure while ignoring anynode_modules
directoriesls
aliases tols -1
so files/directories displayed in the current working directory are listed one per lineni
aliases to a modification ofnpm init
which runsnpm pkg set type="module"
to settype
tomodule
inpackage.json
after initialization.path
aliases toecho "$PATH" | tr ":" "\n" | nl
which displays an easily readable list of path variables instead of the single line of variablesecho $0
outputs
Current dotfiles (.zprofile
, .zshrc
, profile
, and .gitconfig
) are included at the bottom of the gist after the final DANGER
section.
TODO: Better dotfile management.
Reset PATH
to system default, uninstall/delete Homebrew/Volta and associated packages, and reset zsh
dotfiles
# Reset PATH to default
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
# Delete Volta and all installed packages
rm -rf $HOME/.volta
# Uninstall Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
# If anything remains after uninstalling for some reason, you can delete the entire Homebrew directory
rm -rf /opt/homebrew
# Reset zsh dotfiles
rm -rf $HOME/.zprofile $HOME/.zshrc $HOME/.zsh_history $HOME/.zsh_sessions
Install Go and IPFS
No longer using Go or IPFS Kudo, migrating to Helia.
# Install Go
curl --remote-name https://dl.google.com/go/go1.20.4.darwin-arm64.pkg
sudo installer -pkg go1.20.4.darwin-arm64.pkg -target /
rm go1.20.4.darwin-arm64.pkg
go version # open new terminal and check go version
# Install IPFS Kudo
curl --remote-name https://dist.ipfs.tech/kubo/v0.16.0/kubo_v0.16.0_darwin-arm64.tar.gz
tar -xvzf kubo_v0.16.0_darwin-arm64.tar.gz
sudo bash kubo/install.sh
rm -rf kubo kubo_v0.16.0_darwin-arm64.tar.gz
ipfs --version # ipfs version 0.16.0
Install Rustup
Not installing right now cause Rust is cool but writing Rust is a lifestyle and I'm not ready for a long term commitment. And anyway, at this point shouldn't I just learn Zig instead?
curl https://sh.rustup.rs -sSf | sh # Select 1) Proceed with installation (default)
source "$HOME/.cargo/env"
Install and Configure AWS CLI
No longer using AWS CLI cause YOLO.
curl --remote-name "https://awscli.amazonaws.com/AWSCLIV2.pkg" -s # Download the AWS CLI installer
sudo installer -pkg AWSCLIV2.pkg -target / # Use the installer command to unzip the package
rm AWSCLIV2.pkg # Delete the installer package
aws configure # Configure AWS Access Key ID and Secret Access Key
aws --version # Check AWS CLI version
Very cool, thank you for sharing