| Work | Setup | Using homebrew for package management
Using homebrew for package management

Install homebrew

From instructions on https://brew.sh

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

Add the brew command to your ~/.zshrc file

# Use `brew` command in shell
export PATH="/opt/homebrew/bin:$PATH"

Install Postgres on Mac

brew install postgresql

Start Postgres

brew services start postgres

Troubleshooting

Restart Postgres

brew services restart postgresql

Check the status of services

brew services

Check logs

tail /usr/local/var/log/postgres.log

Upgrade Postgres

brew postgresql-upgrade-database

Check Postgres Version

brew info postgres

Install rbenv

brew install rbenv

Add the rbenv command to ~/.zshrc

# Use `rbenv` command in shell
eval "$(rbenv init -)"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

Install nvm

Install node version manager to easily switch between NodeJS versions

brew install nvm
mkdir ~/.nvm

Add the following to your zsh profile nano ~/.zshrc to always make the nvm command available

# Use `nvm` command in shell
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

Restart your terminal or run source ~/.zshrc to reload this file.

List all available NodeJS versions

nvm ls-remote

Install the latest available LTS version

nvm install --lts

Install Redis

brew install redis
brew services start redis

Install ImageMagick / RMagick

brew unlink imagemagick
brew install imagemagick@6
brew link imagemagick@6 --force

brew uninstall pkg-config
brew install pkg-config
brew unlink pkg-config && brew link pkg-config

Troubleshooting

RMagick2.bundle (LoadError) use pristine to force a restore.

gem pristine rmagick

Install ElasticSearch

Install JDK

brew install homebrew/cask-versions/adoptopenjdk8

Find the desired version of elastic search

brew search elasticsearch

To install, Install the latest ElasticSearch:

brew install elasticsearch

// start elasticsearch
brew services start elasticsearch

To install ElasticSearch@6:

brew install elasticsearch@6

// start elasticsearch
brew services start elasticsearch

// add path to zshrc
echo 'export PATH="/usr/local/opt/elasticsearch@6/bin:$PATH"' >> ~/.zshrc

Check installed version

curl -X GET http://localhost:9200/

To uninstall elasticsearch:

// check if it is currently installed, if it is, it will show the path otherwise it will show "Not installed"
brew info elasticsearch

brew uninstall elasticsearch
brew stop elasticsearch

// remove all remaining files and folders
rm -rf /usr/local/var/lib/elasticsearch/
rm -rf /usr/local/var/log/elasticsearch/elasticsearch_jerome.log
rm -rf /usr/local/var/elasticsearch/plugins/
rm -rf /usr/local/etc/elasticsearch/

Install ngrok

 brew install ngrok

Sign into ngrok.com and retrieve your auth token.

Add your auth token to ngrok's local configuration

 ngrok authtoken <token>

Start ngrok

ngrok http 3000

## Or if using a paid subdoman
ngrok http -subdomain=<yoursubdomain> 3000

Install tree

brew install tree

Instead of using ls you can use tree to see your directories laid out in a tree structure

More details: https://formulae.brew.sh/formula/tree

Install Overmind

brew install tmux overmind

https://github.com/DarthSim/overmind

Install Yarn

brew install yarn

zshrc profile

Here's an example of my ~/.zshrc file after installing brew, rbenv, nvm, vscode.

# Use `brew` command in shell
export PATH="/opt/homebrew/bin:$PATH"

# Use `rbenv` command in shell
eval "$(rbenv init -)"
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1)"

# Use `nvm` command in shell
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

# Use VSCode `code` command in shell
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

# Use Nano as default editor
export EDITOR=nano