Skip to content

Instantly share code, notes, and snippets.

@bhuvidya
Last active February 25, 2024 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhuvidya/1f969977b94703be2b9b296cb75b88c8 to your computer and use it in GitHub Desktop.
Save bhuvidya/1f969977b94703be2b9b296cb75b88c8 to your computer and use it in GitHub Desktop.
Setting up a macbook m1 pro for my dev work from scratch.

System Preferences

  • trackpad - tap to click, tracking speed fast, set all other gestures on
  • software update - turn auto update OFF
  • siri off
  • general
    • allow handoff
    • turn off "Close windows when quitting an app"
  • desktop and screensaver - setup screensaver, and hot corners: top left for screen lock, top right for put display to sleep
  • dock
    • autohide, bottom, always show wfi, bluetooth, focus, screen mirroring, display, keyboard brightness, sound and time machine icons
    • clock 24 hours
    • spotlight OFF in menu bar
  • mission control
    • don't auto arrange spaces based on usage
  • siri - OFF
  • accessibility
    • ponter control - enable dragging, three-finger drag
  • network
    • wifi / advanced / dns: google servers 8.8.8.8 and 8.8.4.4, and add "local" to search domains
  • sound - play feedback when volume is changed
  • touch id - add all the fingers you want
  • keyboard
    • shortcuts - add the Ctrl+1 etc shortcuts for mission control/spaces
    • text - tweak "Text" settings to get rid of auto-correct etc
    • make repeat and delay til repeat their fastest settings

Standard Apps

  • finder - set preferences and customise toolbar

Rosetta

Install Rosetta so that we can run apps not built for Apple silicon:

$ softwareupdate --install-rosetta

Apps

  • 1password
  • nordvpn
  • VLC
  • zoom
  • skype
  • spotify
  • chrome
  • firefox
  • tor
  • audacity
  • pocket casts
  • pocket
  • pages
  • numbers
  • keynote
  • garage band
  • handbrake
  • iexplorer
  • discord
  • sphero edu
  • the unarchiver
  • iMessage - check settings on iPhone to make sure text message forwarding is on
  • tg pro (cpu temp etc)

Chrome

We want chrome to remember which windows belonged to which desktops when restarting. See https://superuser.com/questions/1111535/how-can-i-make-osx-remember-the-desktop-assignment-of-different-chrome-windows.

$ defaults write com.google.Chrome NSWindowRestoresWorkspaceAtLaunch -bool YES

VLC

Set "fullscreen" mode to native in preferences.

macos tweaks

Misc macOS stuff

iPhone tethering via USB

When tethering via USB, the system can sometimes be still using the normal WIFI routre settuings for DNS resolution. Use this to manually set the DNS settings for the USB network connection:

$ networksetup -setdnsservers "iPhone USB" 8.8.8.8 8.8.4.4
$ networksetup -setsearchdomains "iPhone USB" local$
$ dscacheutil -flushcache

Software Development Stuff

Apps

  • slack
  • sourcetree
  • xcode w/ cmdline tools

xcode command line tools

$ xcode-select --install

Homebrew

Install as per https://brew.sh. Some standard brew installs:

$ brew install wget
$ brew install imagemagick
$ brew install ffmpeg
$ brew install youtube-dl
$ brew install exiftool
$ brew install tree

And some fun stuff

$ brew install samtay/tui/tetris
$ brew install toilet
$ brew install cmatrix
$ brew install asciiquarium

Shell

Change to latest version of bash via homebrew:

$ brew install bash
$ sudo vi /etc/shells # add "/opt/homebrew/bin/bash" to the end of the file
$ chsh -s /opt/homebrew/bin/bash

Preferences:

  • select "Close if the shell exited cleanly" in "Shell" tab

FZW, see https://github.com/junegunn/fzf

$ $(brew --prefix)/opt/fzf/install

Vim

Install pathogen as per https://www.vim.org/scripts/script.php?script_id=2332

$ mkdir -p ~/.vim/autoload ~/.vim/bundle
$ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

Install NERDTree as per https://github.com/preservim/nerdtree

$ git clone https://github.com/preservim/nerdtree.git ~/.vim/bundle/nerdtree

Install EditorConfig as per https://github.com/preservim/nerdtree

$ git clone https://github.com/editorconfig/editorconfig-vim ~/.vim/bundle/nerdtree

MySQL

Use DBNgin to install MySQL 5.7 and MySQL 8. Use different ports for each. Once installed set the root password in each (mainly because phpmyadmin needs a password). For 5.7:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'mwmGZN]%o_1n4pltQc6l6=zIjtd$lr%l';

And for MySQL 8:

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'mwmGZN]%o_1n4pltQc6l6=zIjtd$lr%l';

Then create a ~/.my.cnf file for root login credentials.

php

Use the approach as in https://getgrav.org/blog/macos-monterey-apache-multiple-php-versions. In other words we use homebrew:

$ brew tap shivammathur/php

All info about installing, upgrading, re-linking etc can be found at github repo

https://github.com/shivammathur/homebrew-php

The ini files can be found in /opt/homebrew/etc/php/.... Other info from homebrew:

To restart shivammathur/php/php after an upgrade:
  brew services restart shivammathur/php/php
Or, if you don't want/need a background service you can just run:
  /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize

You may need to edit the php ini files at some stage:

$ php --ini
$ vi /opt/homebrew/etc/php/7.4/php.ini

Some common edits:

  • Sometimes craft cms backend needs a lot of input vars - max_input_vars=6000

phpmyadmin

Use homebrew to install. Then add to the bottom of /opt/homebrew/share/phpmyadmin/config.inc.php:

$cfg['Servers'][1]['host'] = '127.0.0.1';

// $cfg['blowfish_secret'] = 'dht-+@+3M[z%$+vuQ3Q|UlEJ|H}3WoDofU[*jLm#CY3';

$cfg['ShowAll'] = true;
$cfg['MaxRows'] = 100;

//$cfg['NavigationTreeDisableDatabaseExpansion'] = true;
$cfg['MaxNavigationItems'] = 200;
$cfg['NavigationTreeDisplayItemFilterMinimum'] = 200;
$cfg['NavigationTreeEnableGrouping'] = false;

// $cfg['TempDir'] = '/tmp';

Setting host to 127.0.0.1 rather than localhost is important.

To make sure you can use phpmyadmin in valet, do the following:

$ cd /opt/homebrew/Cellar/phpmyadmin/5.2.1/share/phpmyadmin   # use correct version in path!
$ valet link pma.valet --secure

composer

See https://getcomposer.org/download/ for downloading into a tmp dir. Then create /usr/local/bin and mv the file there.

$ sudo mkdir /usr/local/bin
$ sudo mv composer.phar /usr/local/bin/composer

Also, it's handy to allow composer to use as much memory as possible. See https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors

$ export COMPOSER_MEMORY_LIMIT=-1

UPDATE

See https://joostvanveen.com/run-composer-1-and-2-simultaniously

Install Composer globally, following the instructions from https://getcomposer.org/doc/00-intro.md#installation-linux-unix-macos. This will install the latest Composer 2 version in /usr/local/bin.

  • (on Mac you can simply run brew install composer)
  • Move composer to composer2: mv /usr/local/bin/composer /usr/local/bin/composer2
  • CD to the /usr/local/bin/ folder: /usr/local/bin/
  • Download the latest V1 version from https://getcomposer.org/download/1.10.17/composer.phar : wget https://getcomposer.org/download/1.10.17/composer.phar
  • Make the downloaded phar file executable: chmod 755 composer.phar
  • Rename composer to composer1: mv /usr/local/bin/composer.phar /usr/local/bin/composer1
  • Now create a symlink for the global version you want to use: ln -s /usr/local/bin/composer1 /usr/local/bin/composer. If you are using a local PHP switcher like dnsmasq or valet, make sure to use composer1 as your global Composer version - otherwise you will get Composer errors if you are on PHP < 7.2.0. If you never run PHP < 7.2.0 locally, you should use Composer 2 as your default.
  • To use global Composer: run composer --version
  • To use global Composer 1: run composer1 --version
  • To use global Composer 2: run composer2 --version

nvm

See https://github.com/nvm-sh/nvm for basic install. Install various versions of node/npm:

$ nvm install node
$ nvm install 16
$ nvm install 14
$ nvm install 12

yarn

$ nvm use 18
$ npm install --global yarn

github

Install the github CLI and then use it to cache credentials.

$ brew install gh
$ gh auth login

See

vscode

Instructions here: https://code.visualstudio.com/docs/setup/mac

valet

$ composer global require laravel/valet
$ valet install

If for some reason you get a "Bad gateway" when trying to load a local site, try the following in turn:

$ valet restart
$ valet install
$ valet unisolate ...then... valet isolate php@7.4

ngrok

See https://ngrok.com/download.

$ brew install ngrok/ngrok/ngrok

aws-cli

Follow the instructions here: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html. And then setup the ~/.aws/{config,credentials} files.

exiftool

Follow the instructions for installing on Unix https://exiftool.org/install.html. Then link to the perl executable so that it ends up in the homebrew bin:

$ ln -s /opt/homebrew//Cellar/perl/5.34.0/bin/exiftool /opt/homebrew/bin/exiftool

Heroku

See https://devcenter.heroku.com/articles/heroku-cli. Install via homebrew.

$ brew tap heroku/brew && brew install heroku
$ heroku autocomplete

Mongodb

Install the Atlas Mongodb CLI tool, and mongosh:

$ brew install mongocli
$ brew install mongosh

Then install the mongodb driver for each php version. See

For php 8.2 (the simplest):

$ sudo pecl install mongodb
$ pecl list
$ php --ri mongodb

For php 8.1 (and similar for other older versions), we have to copy the pcre2.h file into the php ext directory for the current php version (o/w the C compilation of the extension fails)

$ cp /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/Cellar/php@8.1/8.1.13/include/php/ext/pcre/pcre2.h
$ sudo pecl install mongodb
$ pecl list
$ php --ri mongodb

And so on for the other versions. To inspect the homebrew php dirs for each installed version, use

$ ls -l /opt/homebrew/Cellar/php@*

Then maybe install the GUI admin tool, MongoDB Compass. See https://www.mongodb.com/try/download/compass

Docker

See here: https://docs.docker.com/desktop/install/mac-install/

Miscellaneous cmdline tools

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