Skip to content

Instantly share code, notes, and snippets.

@brettsmason
Last active May 9, 2023 08:07
Show Gist options
  • Save brettsmason/c4484d981f74bcf2309d5db4dc85f880 to your computer and use it in GitHub Desktop.
Save brettsmason/c4484d981f74bcf2309d5db4dc85f880 to your computer and use it in GitHub Desktop.
Mac Setup

Mac Setup

Homebrew

Install Homebrew as package manager for macOS:

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

Update everything in Homebrew to recent version:

brew update

Packages

Install packages needed for development:

brew install \
  php \
  mariadb \
  mailhog \
  n \
  fish \
  fisher \
  starship \
  composer \
  pv \
  wp-cli

GUI Applications

Install commonly used GUI applications (feel free to remove any you may not want/need):

brew install --cask \
  firefox \
  google-chrome \
  1password \
  iterm2 \
  visual-studio-code \
  ray \
  fork \
  sequel-ace \
  vlc \
  figma \
  rectangle \
  maccy \
  font-fira-code-nerd-font

Setting up your terminal

iterm2

Open up iterm2 and adjust these settings:

  • Make iterm2 Default Term
  • Preferences ->
    • General -> Window
      • unselect "Native full screen windows"
      • select "close windows when closing an app"
    • Appearance ->
      • Windows
        • select "Hide scrollbars"
      • Tabs
        • unselect "Show tab bar in fullscreen"
      • Dimming
        • Unselect all dimming
    • Profiles -> Window
      • Transparency: 30
      • Style: Full Screen
      • Screen: Main Screen
    • Profiles -> Advanced
      • Semantic History -> Open with editor ... -> VS Code
  • Open new split pane with current directory
  • Natural Text Editing
  • Bring it to fullscreen Command + Enters

Set fish as the default shell

  • check the fish path with which fish. In the examples below it was located at: /opt/homebrew/bin/fish. On older Macs the path might differ.
  • Add fish to the know shells run the command: sudo sh -c 'echo /opt/homebrew/bin/fish >> /etc/shells'
  • Restart your terminal
  • Set fish as the default shell run the command: chsh -s /opt/homebrew/bin/fish
  • Restart your terminal and check if it launched with fish or not
  • Add brew binaries in fish path run the command: set -U fish_user_paths /opt/homebrew/bin/ $fish_user_paths

Add the following to your fish config file ~/.config/fish/config.fish:

# Composer
set PATH $HOME/.composer/vendor/bin $PATH
set PATH $HOME/.config/composer/vendor/bin $PATH

# N
set -gx N_PREFIX $HOME/.n;
set -gx PATH "$N_PREFIX/bin" $PATH;

# Starship
starship init fish | source
source ~/.config/fish/config.fish

Set the prompt to use a nice default:

starship preset nerd-font-symbols > ~/.config/starship.toml

Valet

Installation

To install valet run:

composer global require laravel/valet

Then run:

valet install

PHP Monitor - Ignore for now, not recommended

PHP Monitor (or phpmon) is a lightweight macOS utility app that runs on your Mac and displays the active PHP version in your status bar. It's tightly integrated with Laravel Valet, so you need to have it set up before you can use this app, but it makes switching PHP versions and managing Valet very easy.

To install via Homebrew, run:

brew tap nicoverbruggen/homebrew-cask
brew install --cask phpmon
sudo valet trust

Then to run this automatically when loggin in, go to System Preferences > Users & Groups and add PHP Monitor to login items.

MariaDB

Create file $HOMEBREW_PREFIX/etc/my.cnf.d/developer.cnf and put the following config in it. This will improve database performance when working on large websites.

[server]
join_buffer_size = 256M
table_definition_cache = 10K
innodb_buffer_pool_size = 2G
innodb_log_file_size = 256M

; Only if you think you'll be doing advanced app debugging
; performance_schema = 1

After installation you can access the server without a password providing you run it as the superuser. Run the following and add your own root password. Use the default response to all other questions.

brew services restart mariadb
sudo mariadb-secure-installation

Our practice for development machines is to have a common user that can access all databases. In your terminal start a MySQL session.

Now create a new "orphans" user. 

CREATE USER 'orphans'@'localhost' IDENTIFIED BY 'press';
GRANT ALL PRIVILEGES ON *.* TO 'orphans'@'localhost';

NodeJS

N should already be installed if you have got this far which is our node version manager of choice. To install the latest lts version run:

n lts

Mailhog

To start MailHog just enter the following command in your terminal:

brew services run mailhog

GIT

Set some defaults for GIT:

git config --global user.name "Brett Mason"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main

Mailhog

Docker (optional)

Bonus: Dracula theme everything!

I love the dracula theme and recommend everyone use it as its available for most things. Specifically for this setup, instructions for:

iterm2 VS Code Chrome Firefox fish Starship Sequel Ace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment