My MacOS Setup

July 13, 2018

  MacOS Setup

David Beauchesne

Kevin Cazelles

   

Table of Contents

My MacOS Setup

Inspired by Kevin’s recent post on setting up his new laptop on Debian Stretch, I decided that it was time to reset my Mac BookPro to factory settings. I bought it after a year in my thesis and I’ve grown quite a bit since then in my understanding of programming and computers in general. That also meant that I had a lot of accumulated junk!

I also figured that I should do so using a bash script so that I could make this whole process as reproducible as possible for the next time or if I have to change my laptop for some obscure reason! The goal was to obtain a laptop configuration with minimal user input to recreate as exact a replica as possible of the laptop settings I am currently working with.

Full disclosure, I would not have done this without the help of Kevin, Steve and Nicolas, who gave me great resources and part of their own code to set up their Mac!

My laptop

Here is an overview of the laptop I am working with:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* Laptop info */
sw_vers
  ProductName: Mac OS X
  ProductVersion: 10.13.5
  BuildVersion: 17F77

/* Hardware info */
system_profiler SPHardwareDataType
  Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: MacBookPro11,4
      Processor Name: Intel Core i7
      Processor Speed: 2.2 GHz
      Number of Processors: 1
      Total Number of Cores: 4
      L2 Cache (per Core): 256 KB
      L3 Cache: 6 MB
      Memory: 16 GB
      Boot ROM Version: MBP114.0183.B00

      SMC Version (system): 2.29f24
      Serial Number (system): XXXXXXXXXXXX
      Hardware UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Backups

The only thing I did was to back up the files for my thesis that I only have locally on an external hard drive, which ultimately do not amount to much as most of my files are backed on the cloud. I use a combination of GitHub, MEGASync, Dropbox, ownCloud and Google Drive to manage most of my individual and collaborative projects. This means that the majority of my files can be reaccessed through the web once I’ve reinstalled those software.

Reseting to factory settings

Now the first step was to reset my laptop to factory settings. I googled it and followed most of the instructions found here. I simply did not follow the instructions that targeted time machine, iTunes and iCloud because I had no intention of reinstalling an image of my old laptop or to sell my laptop to someone else.

In essence, here are the steps I followed (but I still recommend reading the detailed documentation here if you wish to go the same route I did):

  1. Make sure that my laptop was connected to the internet (not certain that this was fully necessary at this point)
  2. Restart in recovery mode: Option + Command + R
  3. Erase hard drive:
  4. Disk Utility > Continue
  5. Select main drive, usually Macintosh HD
  6. Erase button
  7. Disk Utility > Quit Disk Utility
  8. Reinstall MacOS and followed instructions. Note that this took a long while and that the progress bar and calculation time were very uninformative! I did some research and found this. Essentially, the progress bar was not progressing but the files were being loaded anyway. It was just a very long process. I was able to ascertain that things were indeed progressing by looking at the log file (Command + L). Ultimately, this process took a few hours. Happily, I started doing this at night so I slept through it!
  9. When I woke up, I simply followed the instructions to set up my laptop, such as my laptop name, passwords, etc.

Setting up my Mac

What came after was reinstalling every software that I needed to reproduce the laptop configuration that I wanted. The script I prepared, which is the core of this post, allows me to install and configure softwares through the terminal and download all the project data I have stored in the cloud.

Software installation is done mostly using the Homebrew, and Cask projects, which are package managers for macOS that allows installation and management of applications on a Mac computer. Homebrew mostly deals with command line software, while Cask is an extension of Homebrew that allows management of graphical applications. Homebrew and Cask can be tapped using brew and brew cask commands in the terminal. See here for some information on their difference and visit the Homebrew website for more information.

#!/bin/bash
### https://sourabhbajaj.com/mac-setup/
## Nice overview of mac setup, much better than this one!
### Don't forget !!!
### cd ~
### chmod a+x macos-settings.sh
### sh macos-settings.sh
##------------- Install XCode Command Line Tools
## Accept license
## use xcode-select -p to check whether Xcode is installed
xcode-select --install
sudo xcodebuild -license
##------------- Installing Homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
##------------- Refresh repositories
brew update
##------------- Tapping (Installing 3rd party repositories)
brew tap osgeo/osgeo4mac
##------------- Utilitaries
brew install --cask adobe-acrobat-reader `# Requires pasasword`
brew install --cask cleanmymac
brew install --cask google-chrome
brew install graphicsmagick
brew install ffmpeg
brew install hugo
brew install imagemagick
brew install mplayer
brew install node
brew install --cask the-unarchiver
brew install --cask transmission
brew install vim
brew install --cask vlc
brew install youtube-dl
brew install wget
brew install --cask clickup
##------------- Mail
brew install --cask thunderbird
# [ULaval setup](https://www.dti.ulaval.ca/system/files/offreservices/Courrier_electronique/guide_le_courrier_electronique_ul.pdf)
# UQAR
# - IMAP:
# - Serveur: corrier.uqar.ca
# - Port: 143
# - SSL: STARTTLS
# - Authentification : Mot de passe normal
# - SMTP
# - Serveur: smtp-mail.outlook.com
# - Port : 587
# - SSL : STARTTLS
# - Authentification : Mot de passe normal
# - Identifiant : Code usager de l’UQAR
#
# ULaval
# - IMAP:
# - Serveur: courriel.ulaval.ca
# - Port: 993
# - SSL: SSL
# - Authentification: Mot de passe normal
# - SMTP
# - Serveur: courriel.ulaval.ca
# - Port: 587
# - SSL: TLS
# - Authentification: Mot de passe normal
# - Identifiant : IDUL de l'ULaval
##------------- Communications app
brew install --cask skype
brew install --cask slack
brew install --cask discord
brew install --cask microsoft-teams
brew install --cask zoom
##------------- Reference manager
brew install --cask mendeley
brew install --cask zotero
# install better bibtex manually: https://retorque.re/zotero-better-bibtex/installation/
##------------- Files Hosting Services
# brew install --cask dropbox
# brew install --cask google-backup-and-sync
# brew install --cask megasync
# brew install --cask owncloud `# Requires pasasword`
brew install --cask onedrive `# For UL, DABEA232@ulaval.ca`
brew install --cask nextcloud `# For inSileco, david.beauchesne@insileco.io`
##------------- Music
brew install --cask spotify
##------------- Password manager
brew install --cask dashlane `# Backup before reset`
##------------- Image editor
brew install --cask xquartz `# Requires pasasword`
brew install --cask inkscape
brew install --cask gimp
##------------- Libre office
## brew install --cask libreoffice
##------------- Atom, Packages, Theme & Keybindings
# Appplication
brew install --cask atom
# Packages
apm install ascii-unicode-escape
apm install atom-beautify
apm install atom-increment
apm install atom-language-r
apm install autocomplete-R
apm install autocomplete-paths
apm install color-picker
apm install dictionary
apm install file-icons
apm install highlight-selected
apm install language-knitr
apm install language-latex
apm install language-markdown
apm install language-sage
apm install latex
apm install latexer
apm install mathjax-wrapper
apm install minimap
apm install minimap-highlight-selected
apm install pdf-view
apm install pigments
apm install platformio-ide-terminal
apm install r-exec
apm install rainbow-csv
apm install tree-view-git-status
apm install wordcount
# Themes
apm install seti-ui
apm install seti-vs-syntax
# Keybindings
echo "'atom-workspace atom-text-editor:not([mini])':
'cmd-enter': 'r-exec:send-command' `# r execution keybind`
'shift-cmd-l': 'custom:insert-pipe' `# r pipe`" >> ~/.atom/keymap.cson
echo "atom.commands.add 'atom-text-editor',
'custom:insert-pipe': ->
atom.workspace.getActiveTextEditor()?.insertText('%>%')" >> ~/.atom/init.coffee
##------------- R and GIS dependencies
brew install java `# Requires pasasword`
brew install geos
brew install proj
brew install libxml2
brew install openssl
brew install gdal
brew install netcdf
brew install poppler
brew install udunits
brew install r
brew install libgit2
brew install --cask rstudio
# brew install gdal2 --with-armadillo --with-complete --with-libkml --with-unsupported
# -------- weird setup for packages, links don't match (2019-05-13)
# Openblas
# For r, dunno why but I needed to create a link to gcc for openblas
# ln -s /usr/local/Cellar/gcc/9.1.0/lib/gcc/9/libgcc_s.1.dylib /usr/local/lib/gcc/9/
#
# Netcdf
# cd /usr/local/opt/
# mkdir netcdf
# mkdir netcdf/lib
# ln -s /usr/local/Cellar/netcdf/4.6.3_1.reinstall/lib/libnetcdf.15.dylib /usr/local/opt/netcdf/lib/
#
# XML2 - for now the path is changes for XCODE
# https://github.com/r-lib/xml2/issues/232
# sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
# Setup R
# Install packages
Rscript -e "download.file('https://gist.githubusercontent.com/david-beauchesne/c43465aa4d3927833c7395f28cd214df/raw/c8c180da3b33c7fe0be7a02da7ec531776cbf7ab/rPackages.R', destfile='~/Desktop/rPackages.R')"
Rscript ~/Desktop/rPackages.R
rm ~/Desktop/rPackages.R
# R Profile
Rscript -e "download.file('https://gist.githubusercontent.com/david-beauchesne/f038ad269d12a872b5b0ce64e9d6d56c/raw/cb2b0d5ba98976fc94b0db5c002b3ade890d69f4/rProfile.R', destfile='~/Desktop/rProfile.R')"
Rscript ~/Desktop/rProfile.R
rm ~/Desktop/rProfile.R
# Configure R java
Rscript -e "download.file('https://gist.githubusercontent.com/david-beauchesne/ca903a7e66fb713071a9907830929b72/raw/0df7672c541443cf813f62819c3d51a745d05685/rJava.R', destfile='~/Desktop/rJava.R')"
Rscript ~/Desktop/rJava.R
sudo R CMD javareconf
rm ~/Desktop/rJava.R
##------------- QGIS
# brew install osgeo/osgeo4mac/qgis2
# ln -s /usr/local/opt/qgis2/QGIS.app/ /Applications/
# pip install psycopg2
# pip install matplotlib
# pip install pyparsing
# pip install requests
# pip install future
# pip install jinja2
# pip install pygments
##------------- Pandoc and Pandoc's filters
brew install pandoc
brew install pandoc-citeproc
pip install pandoc-fignos
pip install pandoc-tablenos
pip install pandoc-eqnos
##------------- Install and setup Git and Github
brew install git
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global user.name "David Beauchesne"
git config --global user.email "david.beauchesne@uqar.ca"
git config --global github.user "david-beauchesne"
brew install git-lfs
git lfs install
# Info on GIT lfs: https://help.github.com/categories/managing-large-files/
##------------- PostgreSQL
brew install postgresql
brew install --cask pgadmin4
##------------- Install jekyll
sudo gem install jekyll jekyll-language-plugin
##------------- Install zsh and prezto (https://codurance.com/2015/03/16/installing-zprezto-a-quick-guide/)
brew install zsh
git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
setopt EXTENDED_GLOB
for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
done
# change shell
chsh -s /bin/zsh
##------------- Terminal
# brew cask install iterm2
# bash -c "$(curl -sLo- https://git.io/vQgMr)"
##------------- Load github repositories
# Build structure of GitHub repo on new MAC - 2021-02
mkdir ~/DB
## Personal projects
mkdir ~/DB/Personnel
cd ~/DB/Personnel
git clone https://github.com/david-beauchesne/recettes.git
git clone https://github.com/david-beauchesne/MapArt.git
## Communications
mkdir ~/DB/Comm
cd ~/DB/Comm
git clone https://github.com/david-beauchesne/CurriculumVitae.git
### Presentations
mkdir ~/DB/Comm/Presentations
#### 2019
mkdir ~/DB/Comm/Presentations/2019
cd ~/DB/Comm/Presentations/2019
git clone https://github.com/david-beauchesne/2019_ForumSciencesMarines_Poster.git
#### 2020
mkdir ~/DB/Comm/Presentations/2020
cd ~/DB/Comm/Presentations/2020
git clone https://github.com/david-beauchesne/DFO-BIO_Intro_presentation.git
#### 2021
mkdir ~/DB/Comm/Presentations/2021
cd ~/DB/Comm/Presentations/2021
git clone https://github.com/david-beauchesne/2021-02-04_Webinaire_IDDPNQL_en.git
git clone https://github.com/david-beauchesne/2021-02-04_Webinaire_IDDPNQL.git
git clone https://github.com/david-beauchesne/2021-02-09-UL_CEA_Cours.git
git clone https://github.com/david-beauchesne/2021-02-12-DFO_MSP.git
## Academia
mkdir ~/DB/Academia
### Projects
mkdir ~/DB/Academia/Projects
#### Cumulative effects St. Lawrence System
mkdir ~/DB/Academia/Projects/NCEA_StLawrence
cd ~/DB/Academia/Projects/NCEA_StLawrence
git clone https://github.com/david-beauchesne/Species_Vulnerability.git
git clone https://github.com/david-beauchesne/Predict_interactions.git
git clone https://github.com/david-beauchesne/MetawebEGSL.git
git clone https://github.com/david-beauchesne/Interaction_catalog.git
git clone https://github.com/david-beauchesne/environmentEGSL.git
git clone https://github.com/david-beauchesne/FoodWeb-MultiStressors.git
git clone https://github.com/david-beauchesne/FoodWeb-CumulativeImpact.git
##### eBiotic
mkdir ~/DB/Academia/Projects/NCEA_StLawrence/eBiotic
cd ~/DB/Academia/Projects/NCEA_StLawrence/eBiotic
git clone https://github.com/eBiotic/Traits.git
git clone https://github.com/eBiotic/Biotic.git
##### eDrivers
mkdir ~/DB/Academia/Projects/NCEA_StLawrence/eDrivers
cd ~/DB/Academia/Projects/NCEA_StLawrence/eDrivers
git clone https://github.com/eDrivers/eDrivers.git
git clone https://github.com/eDrivers/eDriversMS.git
git clone https://github.com/eDrivers/eDriversEx.git
git clone https://github.com/eDrivers/eDriversWorkflows.git
git clone https://github.com/eDrivers/eDriversGrids.git
git clone https://github.com/eDrivers/eDriversApp.git
###### Drivers
mkdir ~/DB/Academia/Projects/NCEA_StLawrence/eDrivers/Drivers
cd ~/DB/Academia/Projects/NCEA_StLawrence/eDrivers/Drivers
git clone https://github.com/eDrivers/ToxicAlgae.git
git clone https://github.com/eDrivers/Shipping.git
git clone https://github.com/eDrivers/SeaSurfaceTemperature.git
git clone https://github.com/eDrivers/SeaLevel.git
git clone https://github.com/eDrivers/SeaBottomTemperature.git
git clone https://github.com/eDrivers/OrganicPollution.git
git clone https://github.com/eDrivers/NutrientInput.git
git clone https://github.com/eDrivers/MarinePollution.git
git clone https://github.com/eDrivers/InvasiveSpecies.git
git clone https://github.com/eDrivers/InorganicPollution.git
git clone https://github.com/eDrivers/Hypoxia.git
git clone https://github.com/eDrivers/Fisheries.git
git clone https://github.com/eDrivers/DirectHumanImpact.git
git clone https://github.com/eDrivers/CoastalDevelopment.git
#### Cumulative effects Navigation TC
mkdir ~/DB/Academia/Projects/CEA_Navigation_TC
cd ~/DB/Academia/Projects/CEA_Navigation_TC
git clone https://github.com/EffetsCumulatifsNavigation/ceanav.git
git clone https://github.com/EffetsCumulatifsNavigation/WebinaireMethode
git clone https://github.com/EffetsCumulatifsNavigation/Methode
git clone https://github.com/EffetsCumulatifsNavigation/Methodology
git clone https://github.com/david-beauchesne/Rapport
git clone https://github.com/EffetsCumulatifsNavigation/ZoneEtude
#### Cumulative effects Scotian Shelf
mkdir ~/DB/Academia/Projects/NCEA_ScotianShelf_DFO-BIO
cd ~/DB/Academia/Projects/NCEA_ScotianShelf_DFO-BIO
git clone https://github.com/david-beauchesne/CumulativeEffects-ScotianShelf
### PhD
mkdir ~/DB/Academia/PhD
cd ~/DB/Academia/PhD
git clone https://github.com/david-beauchesne/Soutenance.git
git clone https://github.com/david-beauchesne/ThesePhD.git
### Project ideas
mkdir ~/DB/Academia/Ideas
cd ~/DB/Academia/Ideas
git clone https://github.com/david-beauchesne/KnowledgeManagement.git
git clone https://github.com/david-beauchesne/KnowledgeGraphs.git
git clone https://github.com/david-beauchesne/Global_FoodWeb_CumulativeImpacts.git
## inSilecoInc
mkdir ~/DB/inSilecoInc/
### Administrative
mkdir ~/DB/inSilecoInc/Admin
cd ~/DB/inSilecoInc/Admin
git clone https://github.com/inSilecoInc/admin
git clone https://github.com/inSilecoInc/inSilecoAdmin.git
### Education
mkdir ~/DB/inSilecoInc/Education
cd ~/DB/inSilecoInc/Education
git clone https://github.com/inSilecoInc/workshop_raster.git
git clone https://github.com/inSilecoInc/interactiveRaster.git
git clone https://github.com/inSilecoInc/workshop_reproducibility.git
git clone https://github.com/sci1031/sci1031.git
### Consultation
mkdir ~/DB/inSilecoInc/Consultation
cd ~/DB/inSilecoInc/Consultation
git clone https://github.com/inSilecoInc/shinySpatialApp.git
### Communication
mkdir ~/DB/inSilecoInc/Communication
cd ~/DB/inSilecoInc/Communication
git clone https://github.com/inSilecoInc/inSilecoInc.github.io.git
git clone https://github.com/inSileco/inSileco.github.io.git
##------------- Reboot
sudo reboot
view raw installMacOS.sh hosted with ❤ by GitHub

The script is not perfect. It still can’t fully execute in one go because I get prompted for credentials for some software (which I plan to remedy on my next setup). I also did have to improve it as I was reinstalling and reconfiguring my laptop, and I will likely keep improving it through time. Ultimately, however, I managed to have an almost fully operational and configured laptop very efficiently.

Building the script and backing up my data did take considerable time, but I started with a very basic understanding of what it meant to reconfigure a laptop. I would not say I’m an expert now, far from it, but the whole process was enlightening and with the script I built I can now easily reset my Mac or a new one just the way I like it, which was the whole point to begin with!

Enjoy!