So you’ve just got your brand new Macbook Pro and you want to start using it effectively? Here are my installation notes relative to Mac OS 10.12 (Sierra) on a Macbook Pro TouchBar ID.

Resources

Table of Content

Pre-requisites: Erase and Re-install

The first things you should do is to securely erase your disk and re-install the OS. It’s not a 100% guarantee of security but let’s say it ensures you start from a clean system.

Secure erase is no longer available under Mac OS Sierra, but the below steps should be sufficient:

  • configure and login the first time with a dummy user
  • Open “System Preference” (in the dock), go to “Security & Privacy”, Select FileVault and turn it on (Copy the encryption key)
  • Wait for the encryption of your disk to finish.
    • in parallel (but not such now it’s really required), open the “App Store” and download your OS
  • Once FileVault has finished:
    • Reboot and use Command + R after the apple logo appears
    • Select Disk Utility: Erase Macintosh HD
    • Select Reinstall macOS Sierra

Preliminary setup: System Preferences

So now you should have setup Mac OS (Sierra 10.12 at the time of writing), it’s time to configure it.

  • (eventually) install now Little Snitch application to monitor closely all connections attemps (and thus allow permanently the once elligible upon configuration of the below steps).
    • Enable the option “Show Local Network” (Upper left dropdown in Monitor window)
  • Open “Keychain Access” app (under Applications / Utilities /), go to the Preferences menu, and select “Show keychain status in menu bar”.
    • It permits to lock the screen on demand.
  • Clean the dock with unnecessary applications
  • Open “System Preferences” (in the dock), go to “Security & Privacy”
    • Under ‘General’: “require password after 5s”.
    • Unlock and select the ‘Advanced’ button (bottom right)
      • Enable “Require a administrator password to access system-wide preference” Disable automatic login and remote control infrared receiver.
    • Under ‘FileVault’, Turn it on

    You should use FileVault from the first day you purchase your Mac. Then all your data is encrypted, including any bad blocks, or on SSD’s the blocks that have not been pre-cleaned.

    • Under ‘Firewall’: Turn on to start the Firewall.
      • Ideally, under the Advanced tab, select the option to “prevent all incoming connections”.
      • Otherwise, enable at least the stealth mode, and disable the other Automatic settings
    • Under ‘Privacy’: be aware of the services using your location.
      • Under ‘About Location Services & Privacy’,
  • Update your laptop (Turn on automatic updates when proposed)
    • In the Apple menu (top left), select “App Store”, go to the ‘Updates’ tab and install the latest updates (you will probably have to restart)

It’s now time to finalize the configuration of the “System Preferences” (in the dock):

  • Adapt your favorite settings in ‘Desktop & Screen Saver’
  • In Dock:
    • reduce the size
    • enable “Magnification”
  • In Mission Control:
    • Untick ‘Automatically rearrange Spaces based on most recent use’
    • (eventually) Untick ‘Group windows by application’
    • Untick ‘Display have separate spaces’
    • Select Dashboard As Space
    • Configure the ‘Hot Corners’ (bottom left button) as follows:
      • top left: ‘Mission Control’
      • bottom left: ‘Desktop’
    • I also prefer to use “ALT Arrow Keys” to switch between spaces. Configure that under Keyboard / ShortCuts under ‘Mission Control’: modify the key binding for “Move to {left right} spaces”.
  • In Displays, untick the ‘Show mirroring options in the menu bar when available’
  • In Keyboard:
    • Under ‘Text’: Disable ‘Add period with double space’ as it lead to strange (unexpected) behaviour like inserting a ‘.’ upon double space… Quite annoying when programming…
    • Under ‘ShortCuts’, select ‘App ShortCuts’ and enable globally your favorites shortcut (“CTRL + {left,right} arrow” in my case) to move to the {next,previous} tab. Trouble is that the consistency of the menu name at this level is still not perfect (some use: ‘Select Next Previous Tab’, while the new standard seems to be ‘Show Next Previous Tab’). So the best is to configure the same shortcuts to cover all cases:
      • click on the ‘+’ button, with Menu title: ‘Select Next Tab’ (beware this is case-sensitive) and in Keyboad SHortcut, press CTRL + right arrow.
      • repeat with ‘Select Next Tab’ and the same shortcut
      • similarly, click on the ‘+’ button, with Menu title: ‘Select Previous Tab’ (beware: this is case-sensitive) and in Keyboad Shortcut, press CTRL + left arrow.
      • repeat with ‘Select Previous Tab’ and the same shortcut
      • You probably want also to reassign the “Quit” Menu (for instance to CTRL+CMD+Q) to avoid accidentally closing your apps
    • Note that for some reason, iTerm does not correctly handle these general settings and need to be tweak accordingly (see below for more details)
    • Under Shortcuts / Accessibility, untick everything
    • If you plan to use Alfred App (especially with the PowerPack), you may want to disable the shortcuts for Spotlight search (CMD+Space) to use it with Alfred.
  • In TrackPad: enable ‘Tap to click’ and increase the ‘Tracking speed’
    • select for One finger “Tap to click”, “dragging” and “Secondary click”. Ensure “Secondary Tap” is checked for Two Fingers
  • In ‘iCloud’: adapt the settings (in particular for the ‘Find My Mac’ option )
  • in ‘Internet Account’, add your favorites accounts (ensure double authentication is enable for all of them)
  • In App Store: select ‘Automatically check for updates’
    • tick all sub-options there
    • review the other settings.
  • In BlueTooth, Turn it off (unless you plan to use a wireless mouse)
  • In Sharing
    • click on the lock to prevent further changes
    • Edit and adapt the computer name
    • ensure all options are disabled
    • (eventually) Allow (for the time of the setup) the ‘Remote Login’ option only for your username (in particular, remove Administrators from the list). This will permit to connect and transfer files from your old Mac to this new one. Remember to disable it afterwards.
  • In Time Machine:
    • tick ‘Show Time Machine in menu bar’
    • select your disk and tick ‘Encrypt backups’
  • In Accessibility,
    • Under General, untick all
    • Under Display, disable ‘Shake mouse pointer to locate’
  • In Printer & Scanners, click on the ‘+’ button
    • right-click on the toolbar, select Customize Toolbar, drop the Advanced menu there
    • Click on ‘Advanced’ to add your UL printer
      • Type: Windows printer via spoolss
      • URL: `smb:///
      • Adapt the Name

In Safari, open the Preferences and in the “General” section, uncheck the option “Open safe files after downloading”. Carefully check all options.

Terminal Applications

  • Install iTerm2 Version 3, the best terminal application under Mac OS
  • You might still wish to use the default Terminal app (under /Applications/Utilities/) as the integration with the TouchBar is better than iTerm2 at the time of writing

iTerm2 configuration

As mentioned above, for some reason, iTerm2 does not correctly handle the general keyboard shortcut settings. Here is how to enforce it:

Open iTerm2 Preferences from the menu

  • Under ‘General’:
    • Untick Confirm ‘Quit iTerm2’
    • tick ‘copied text includes trailing newline’ (a warning box is issued in this case, so don’t worry)
    • tick ‘Smart window placement’
    • untick ‘Native full screen windows’
  • Under ‘Appearance’
    • untick ‘Show activity Indicator’
    • untick ‘Show per-pane title bar with split’
    • untick ‘Show Window number’
    • tick ‘Dim background windows’
    • tick ‘Hide scrollbars’ and ‘Disable transparency for fullscreen windows’
  • Under ‘Profiles’
    • in “General”:
      • select ‘Resuse previous session’s history’, add the tag ‘default’
      • select ‘Applications in Terminal may access clipboard’
    • in “Colors”: you should select the color scheme you like using the ‘Color Presets’ button.
      • personnally I like Darkside
      • tick ‘Smart Cursor Color’
    • in “Text”: see My dotfiles instructions
      • install the Source Code Pro + Powerline Awesome Regular at 14pt (for bot Regular and Non-ASCII font) – Download it and install it
      • Change the Font to “Source Code Pro + Powerline Awesome Regular” (under Fixed Width), Regular, 14pt
      • tick ‘Use a different font for Non-ASCII text’ and use the same font for that (“Source Code Pro + Powerline Awesome Regular”, Regular, 14pt)
      • Note: you might wish to set also this setting in the default Terminal app.
    • In ‘Window’:
      • Columns: 140, Rows: 40
      • tick ‘if showing profile name…’
      • note: if you want to bind a special key combination to launch iTerm (thus in the Default profile), you might want to set the style as ‘Full-Width Top of Screen’
    • In ‘Terminal’: tick ‘Unlimited scrollback’
    • In ‘Session’: tick ‘Do not prompt before closing’
    • In ‘Keys’
      • Load Preset ‘Terminal.app Compatibility’
      • delete the key combinations “CTRL {left,right} arrow” and “CMD+arrow keys” that conflicts with the global settings for tab navigation (see above System Preferences settings)
      • Set a couple of useful key combinations listed in the below table
iTerm Key bindings Action Command Description
SHIFT + left arrow Send Escape Sequence b bash: backward-word
SHIFT + right arrow Send Escape Sequence f bash: forward-word

Once you are really satisfied with the Default profile, you might wish to Duplicate it (through the ‘Other Actions’ menu)

Homebrew – The missing package manager for Mac OS

Install Homebrew as per instructions:

1
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Complementary:

  • Install Homebrew Cask, which “extends Homebrew and brings its elegance, simplicity, and speed to macOS applications and large binaries alike.
  • Install mas-cli, a CLI interface to the applications you installed with the Mac App Store (each has a product identifier which is also used for mas-cli commands).
  • Install Homebrew Bundle which takes care of storing all installed apps and packages in a Brewfile (through brew bundle dump) that can be used to re-install them.
1
2
3
4
5
(old)$> brew install mas         # CLI for Mac App Store - https://github.com/mas-cli/mas
(old)$> brew tap caskroom/cask   # brew cask [...] -- https://caskroom.github.io/
(old)$> brew tap Homebrew/bundle # bring Brewfile management
(old)$> brew bundle dump         # Create a Brewfile embedding all installed apps
(old)$> scp Brewfile <new>:      # Transfer it to your new laptop (assuming SSH keys are configured -- see below)

Now on your new laptop:

1
2
3
4
$> brew install mas
$> brew tap caskroom/cask
$> brew tap Homebrew/bundle
$> brew bundle               # Consumes the local Brewfile to install your apps

Otherwise, a minimal Brewfile is proposed within my dotfiles repository.

To install it:

1
2
3
$> git clone https://github.com/Falkor/dotfiles.git
$> cd dotfiles
$> ./install.sh --brew   # OR 'cd brew && brew bundle -v'

You can update the installed apps and packages using:

$> brew update && brew upgrade
$> brew cu     # cask upgrade from tap buo/cask-upgrade

SSH Keys

You should generate new SSH key pairs for your laptop (use a strong passphrase):

1
2
$> ssh-keygen -t ed25519 -o -a 100     # Generate ~/.ssh/id_ed25519[.pub]
$> ssh-keygen -t rsa -b 4096 -o -a 100 # Generate classical RSA keys (4096 bits)

See also my tutorial on SSH

Now you can authorize the SSH key from your other laptop (in ~/.ssh/authorized_keys) to ensure you can login by SSH from your old laptop to your new one (assuming you allow ‘Remote Login’ under the ‘Security & Privacy’ System Preferences.)

1
(old)$> ssh <login>@<IP>  # Adapt accordingly

Transferring Files

Once SSH is set, you can start transferring files using rsync from your old laptop to the new one as follows (see useful rsync options) however this requires a recent version 3.X of rsync to install via Homebrew

1
2
3
4
5
$> brew tap homebrew/dupes
$> brew install rsync
# Now you should have the version 3.X
$> rsync --version
rsync  version 3.1.2  protocol version 31

Eventually repeat the operation on your old laptop to ensure you also run the 3.x version.

1
2
3
4
5
6
(old)$> rsync --version
rsync  version 3.1.2  protocol version 31
(old)$> which rsync
/usr/local/bin/rsync      # installed from Homebrew
(old)$> /usr/bin/rsync --version
rsync  version 2.6.9  protocol version 29

Now you can transfer your data from your old Mac to the new one using the rsync command:

rsync --rsync-path=/usr/local/bin/rsync -avzu -NHAX --protect-args --fileflags --force-change [...]

These options preserve extended attributes on folders etc. proper to Mac.

For instance, to transfer everything from under the ~/git/* folder, and assuming <new> is your new laptop IP:

1
(old)$> rsync -avzu -NHAX --protect-args --fileflags --force-change ~/git/./   <new>:git/     # Notice the /./

Shell integration

See Falkor/dotfiles on Github, which have been changed to follow XDG guidelines.

$> mkdir -p ~/git/github.com/Falkor/
$> cd ~/git/github.com/Falkor/
$> git clone https://github.com/Falkor/dotfiles.git
$> cd dotfiles
$> ./install.sh --recommended     # OR ./install.sh --all

Editors

You need a good editors ;) Here are a few suggestions:

  • Emacs-mac
  • VIM
  • Atom, A hackable text editor for the 21st Century
  • Spacemacs: Emacs advanced Kit focused on Evil i.e. the best of emacs and vim

Installation:

$> brew tap railwaycat/emacsmacport
$> brew install emacs-mac atom vim

Configuration:

I like to always see in the menu bar:

Finder

In Finder Menu, select Preferences.

  • In General, select all checkboxes for the items to be shown on the Desktop.
  • In Sidebar,
    • under Favorites, uncheck AirDrop (enable it only on demand) and check your homedir
    • under “Devices”, check “your MacBook Pro” and uncheck “iDisk”;
    • under “Shared”, uncheck “Back to My Mac” and “Bonjour Computers”
  • In Advanced,
    • tick ‘Show all filename extensions’
    • check “Empty Trash Securely” (no longer available under Sierra it seems)

Make the Library folder visible from the finder:

1
$> chflags nohidden ~/Library

RVM

RVM (Ruby Version Manager) can be installed using my Falkor/dotfiles](https://github.com/Falkor/dotfiles) install script:

$> cd ~/git/github.com/Falkor/dotfiles
$> ./install.sh --rvm

Otherwise, follow the official instructions.

Migrating to a New GPG Key

References:

See my tutorial on GPG.

Specific Application configuration

Below are some configuration notes for the [paid] applications I use.

1Password

A must have for password management and integration in different browser. You can enable TouchID in the Preferences General menu to unlock your 1Password vault.

Alfred App

Just don’t hesitate to pay for the Powerpack – The workflow capabilities it brings (through the repo) is just amazing. Here are the [workflows](https://www.alfredapp.com/workflows/) I use:

  • One for opening iTerm2 with CTRL + CTRL (as previously in Vizor). This mean that you have to configure the Default profile of iTerm to fullscreen from top

Marked 2 (markdown viewer)

Open the Preferences pane, Under Processor, select ‘Discount (GFM)’

Omnigraffle

If you need to import the stencils from Omnigraffle 6, they are located in ~/Library/Containers/com.omnigroup.OmniGraffle6/Data/Library/Application\ Support/The\ Omni\ Group/OmniGraffle

VirtualBox / vagrant

Change the default folder for VMs:

$> mkdir -p /Users/Shared/VMs/virtualbox

Run virtualbox, in Preferences, change the “Default Machine Folder” accordingly.

Music management with beets

$> pip install beets
# Those are required for some plugins
$> pip install pyacoustid requests pylast
$> brew install chromaprint
$> mkdir ~/.local/beets      # Create data dir for beets to store music DB
$> beet config -e         # Edit YAML configuration (`~/.config/beets/`)
[...]
$> beet config    # Typical configuration
directory: /Users/Shared/Music
asciify_paths: yes
library: ~/.local/beet/musiclibrary.db
plugins: chroma fromfilename fetchart lyrics