Getting Started

Macbook Setup

Getting Started

The setup assistant will launch once you turn the computer on. Enter your language, time zone, Apple ID, and so on. The first thing you should do is update macOS to get the latest security updates and patches.

Homebrew

Install the Homebrew package manager. This will allow you to install almost any app from the command line.

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

Make sure everything is up to date.

brew update

Install Apps

Here are some the programs I always install.

TIP

Don't install Node.js through Homebrew. Use nvm (below).

ProgramPurpose
Sublime Texttext editor
Google Chromeweb browser
Firefoxweb browser
Rectanglewindow resizing
iTerm2terminal
Slackcommunication
Spotifymusic
MySqldatabase
Sequel Prodatabase UI
TransmitFTP tool
PostmanAPI tool
brew install \
  git \
  yarn \
  make &&

# GUI programs
brew install --cask \
  sublime-text \
  google-chrome \
  firefox \
  rectangle \
  iterm2 \
  slack \
  spotify \
  mysql \
  sequel-pro \
  transmit \
  postman

bash

Catalina comes with zsh as the default bash. Install Oh My Zsh for sensible defaults.

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

Node.js

Use Node Version Manager (nvm) to install Node.js. This allows you to easily switch between Node versions, which is essential.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash

Install

Install the latest version.

nvm install node

Restart terminal and run the final command.

nvm use node

Confirm that you are using the latest version of Node and npm.

node -v && npm -v

Update

For later, here's how to update nvm.

nvm install node --reinstall-packages-from=node

Change version

Here's how to switch to another version and use it.

nvm install xx.xx
nvm use xx.xx

And to set the default:

nvm alias default xx.xx

Git

The first thing you should do with Git is set your global configuration.

touch ~/.gitconfig

Input your config and create some aliases.

[user]
  name   = Firstname Lastname
  email  = you@example.com
[github]
  user   = username
[alias]
  a      = add
  ca     = commit -a
  cam    = commit -am
  cm     = commit -m
  s      = status
  pom    = push origin master
  pog    = push origin gh-pages
  puom   = pull origin master
  puog   = pull origin gh-pages
  cob    = checkout -b
  co     = checkout
  fp     = fetch --prune --all
  l      = log --oneline --decorate --graph
  lall   = log --oneline --decorate --graph --all
  ls     = log --oneline --decorate --graph --stat
  lt     = log --graph --decorate --pretty=format:'%C(yellow)%h%Creset%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset'

With the above aliases, I can run git s instead of git status, for example. The less I have to type, the happier I am.

SSH

Simplify the process of SSHing into other boxes. Create an SSH config file.

mkdir ~/.ssh && touch ~/.ssh/config

Add the following contents, changing the variables for any hosts that you connect to. Using the below will be the same as running ssh -i ~/.ssh/key.pem user@example.com.

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa

Host myssh
  HostName example.com
  User user
  IdentityFile ~/.ssh/key.pem

Now just run the alias to connect.

ssh myssh

Generate SSH Key

You can generate an SSH key to distribute.

ssh-keygen -t rsa -b 4096 -C "email@example.com"

Add key.

ssh-add -K ~/.ssh/id_rsa

Settings

I don't like a lot of the Apple defaults so here are the things I always change.

To get the Home folder in the finder, press CMD + SHIFT + H and drag the home folder to the sidebar.

General

  • Set Dark mode
  • Make Google Chrome default browser

Dock

  • Automatically hide and show Dock
  • Show indicators for open applications

Keyboard

  • Key Repeat -> Fast
  • Delay Until Repeat -> Short
  • Disable "Correct spelling automatically"
  • Disable "Capitalize words automatically"
  • Disable "Add period with double-space"
  • Disable "Use smart quotes and dashes"

Security and Privacy

  • Allow apps downloaded from App Store and identified developers
  • Turn FileVault On (makes sure SSD is securely encrypted)
  • Turn Firewall On (extra security measure)

Change computer name

  • Change computer name
  • Make sure all file sharing is disabled

Users & Groups

  • Add "Rectangle" to Login items

Defaults

A few more commands to change some defaults.

# Show Library folder
chflags nohidden ~/Library

# Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES

# Show path bar
defaults write com.apple.finder ShowPathbar -bool true

# Show status bar
defaults write com.apple.finder ShowStatusBar -bool true

# Prevent left and right swipe through history in Chrome
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false

Application Settings

Chrome

  • Turn off "Warn before quitting"
  • Install uBlock Origin
  • Install React DevTools
  • Install Redux DevTools
  • Install JSONView
  • Install DevTools Theme - New Moon
  • Settings
    • Set theme to "Dark"
    • Go to chrome://flags and set Developer Tools Experiments to "Enabled"
    • Go to Experiments and select "Allow custom UI themes"

Sublime Text

  • Press CMD + SHIFT + P and click "Install code command in PATH".
  • Install Prettier
  • Install Material Theme
  • Install ESLint
  • Install Prettier
  • Keyboard Shortcuts
    • Copy Line Down - CMD + SHIFT + E
    • Delete Line - CMD + SHIFT + D
    • Reload Window - Remove Development Mode from When
    • Format Document - CMD + SHIFT + L

Rectangle

  • Full Screen: CMD + SHIFT + ' (prevents messing with other commands)
  • Left Half: CMD + OPTION + LEFT
  • Right Half: CMD + OPTION + RIGHT

iTerm2

Conclusion

That sums it up for current preferences on setting up a MacBook Pro. Next section we will talk about the specif environment to get developing locally.

Local Environment

Sites Folder

Create a Sites folder where you will serve all your local websites from.

cd $HOME && mkdir Sites

Now your Sites folder is created and this is the directory that you will park with laravel once you have completed the setup for Laravel.

Composer

Composer is a dependency manager for php. It will need to be downloaded and installed before Laravel can be setup. This will require homebrew to be installed.

Install

Open up your terminal and type:

brew install composer

After it your should see something like this:

==> Installing homebrew/php/composer
==> Downloading https://homebrew.bintray.com/bottles-php/composer-1.3.2.el_capitan.bottle.tar.gz
    ######################################################################## 100.0%
==> Pouring composer-1.3.2.el_capitan.bottle.tar.gz
  /usr/local/Cellar/composer/1.3.2: 5 files, 1.7M

Let’s test it, try to run the command below:

composer --version

If you saw a number of version then everything has gone fine.

Laravel Valet

For PHP we use Laravel Valet. With Valet installed you do not need to update your hosts file or provision a server locally. You just clone your project from Github and whatever the name of your folder is, will be the domain host. So if you have a project called water-for-everyone your local domain would resolve to http://water-for-everyone.test.

Valet works out of the box with both Laravel and WordPress with no further configuration.

In addition to easy domains, you have access to SSL with the CLI command valet secure and temporary Ngrok urls for sharing your local environment with valet share.

Install

brew update

Next, you should use Homebrew to install PHP:

brew install php

After installing PHP, you are ready to install the Composer package manager. In addition, you should make sure the ~/.composer/vendor/bin directory is in your system's "PATH". After Composer has been installed, you may install Laravel Valet as a global Composer package:

in your ~/.bashrc add these lines:

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc

Then reload terminal then check ~/.bashrc:

source ~/.bashrc

Check if ~/.composer/vendor/bin is in your path

$PATH

Output should be something like this and contain ~/.composer/vendor/bin

/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/web/bin:~/.composer/vendor/bin

After Composer has been installed, you may install Laravel Valet as a global Composer package:

composer global require laravel/valet

Finally, you may execute Valet's install command. This will configure and install Valet and DnsMasq. In addition, the daemons Valet depends on will be configured to launch when your system starts:

valet install

Once Valet is installed, try pinging any *.test domain on your terminal using a command such as ping foobar.test. If Valet is installed correctly you should see this domain responding on 127.0.0.1.

Valet will automatically start its required services each time your machine boots.

PHP Versions

Valet allows you to switch PHP versions using the valet use php@version command. Valet will install the specified PHP version via Homebrew if it is not already installed:

valet use php@7.2

valet use php

TIP

Valet only serves one PHP version at a time, even if you have multiple PHP versions installed.

Database

After MySql Sequel Pro have been installed, you can connect to your database at 127.0.0.1 using the root username and an empty string for the password.

The park Command

The park command registers a directory on your machine that contains your applications. Once the directory has been "parked" with Valet, all of the directories within that directory will be accessible in your web browser at http://<directory-name>.test:

cd ~/Sites

valet park

That's all there is to it. Now, any application you create within your "parked" directory will automatically be served using the http://<directory-name>.test convention. So, if your parked directory contains a directory named "laravel", the application within that directory will be accessible at http://laravel.test. In addition, Valet automatically allows you to access the site using wildcard subdomains (http://foo.laravel.test).

If you get stuck or it is not working visit the official documentation for laravel

Homebrew

Homebrew is a package manager for MacOS. When you install Laravel Valet you'll install PHP, Mysql, and many other dependencies with Homebrew. If you need help installing Homebrew you can reference the Macbook Setup guide above about Homebrew

Database Management

For managing your MySQL databases, you can install SequelPro. Additionally, Navicat is another great option if you'd like to purchase it yourself. If there's a specific reason you need the company to buy it, just let us know. Otherwise, SequelPro is a great for most database needs.

If you followed the setup documentation above SequelPro will already be installed on your machine.

Version Control

We use Git to version all of our code and store it in Github.

Last updated: 4/7/2021, 8:18:43 PM