Skip to content

Instantly share code, notes, and snippets.

@amitmbee
Created September 14, 2019 02:41
Show Gist options
  • Save amitmbee/c3d72e7fcda29f27eef8d543211b4d52 to your computer and use it in GitHub Desktop.
Save amitmbee/c3d72e7fcda29f27eef8d543211b4d52 to your computer and use it in GitHub Desktop.

Helpful Information for MacOS

The below information is current as of 2019-09-02 and applies to MacOS 10.14.x (Mojave).

This document is meant to serve as an aid and reference in preparing a MacOS system, the process and .dotfiles are completed manually. Note that the default Terminal is replaced with iTerm2 and Bash v5.

For additional information or help please feel free to ping via https://www.coreygo.com.

System information commands

  • uptime displays current system uptime
  • system_profiler SPHardwareDataType displays hardware overview
  • system_profiler -listDataTypes lists available system_profiler options
  • system_profiler -detailLevel basic > ~/system_profile.txt outputs to text document for sharing

Security

Review the macOS Security and Privacy Guide and Stronghold.

  • Set root password
    • sudo passwd -u root
  • For Development (disable macOS Gatekeeper)
    • sudo spctl --master-disable

Software updates

  • softwareupdate -l
  • sudo softwareupdate -iaR --verbose

System

  • Set login screen message
    • sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "coreygo.com"
  • Disable screenshot drop shadow
    • defaults write com.apple.screencapture disable-shadow -bool true && killall SystemUIServer
  • Hide Desktop
    • defaults write com.apple.finder CreateDesktop false && killall Finder
  • Show All Files
    • defaults write com.apple.finder AppleShowAllFiles YES
    • CMD+SHIFT+.

Networking

  • Set computer name (System Preferences → Sharing)

    sudo scutil --set ComputerName "entropy"
    sudo scutil --set HostName "entropy"
    sudo scutil --set LocalHostName "entropy"
    sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName $(scutil --get LocalHostName)
  • Disable .DS_Store on network shares

    • defaults write com.apple.desktopservices DSDontWriteNetworkStores true
  • Speed up SMB client to Synology NAS by disabling packet signing

    sudo -s
    echo "[default]" >> /etc/nsmb.conf
    echo "signing_required=no" >> /etc/nsmb.conf
    exit

Software

Homebrew

  • Xcode Command Line Tools

    • xcode-select --install
  • Homebrew

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

    • brew tap caskroom/cask
    • brew tap caskroom/versions
    • brew tap caskroom/drivers
    • brew tap caskroom/fonts
    • brew tap homebrew/services
    • brew tap buo/cask-upgrade (brew cu)
    • brew install vitorgalvao/tiny-scripts/cask-repair (cask-repair)
  • Homebrew FAQ (man page)

    • brew update-reset && brew update
    • brew upgrade && brew cu
    • brew cleanup -s
    • rm -rf $(brew --cache)
    • brew missing and brew doctor and brew config
    • brew uninstall {{package name}} to uninstall a Homebrew package
    • brew cask uninstall {{cask name}} to uninstall a Homebrew cask package
    • brew untap {{cask name}} to untap a Homebrew cask

    Post Install

    cat << 'EOF' >> ~/.secrets
    # Set Homebrew's GitHub access token
    export HOMEBREW_GITHUB_API_TOKEN=
    EOF

    Additional Post Install

    cat << 'EOF' >> ~/.bashrc
    # Export Homebrew environment variables
    export HOMEBREW_FORCE_VENDOR_RUBY=1
    export HOMEBREW_FORCE_BREWED_GIT=1
    export HOMEBREW_FORCE_BREWED_CURL=1
    
    # Set alias bup to update Homebrew
    alias bup="brew update-reset && brew update && brew upgrade && brew cu && brew cleanup -s && rm -rf $(brew --cache) && brew missing && brew config && brew doctor"
    EOF
  • Search for Formulae

    • brew search google (includes formulae and casks)
  • Search for Casks

Fonts

  • Search installed fonts: system_profiler SPFontsDataType | grep Fura

  • Search Homebrew fonts: brew search /roboto/

  • Install (via brew or source): Fira Code, Hack, Nerd Fonts, Source Code Pro, Roboto, additional "cloud" fonts can be installed via the Adobe Creative Cloud app

    • brew cask install font-roboto
    • brew cask install font-firacode-nerd-font
    • brew cask install font-fira-code
    • brew cask install font-meslo-nerd-font
    • brew cask install font-sourcecodepro-nerd-font
    • brew cask install font-source-code-pro

Terminal

  • Create ~/.bash_profile if needed and source ~/.bashrc

    • if [ ! -f ~/.bash_profile ]; then echo '[ -r ~/.bashrc ] && . ~/.bashrc' >> ~/.bash_profile; fi;
  • iTerm2

    • brew cask install iterm2-beta
      or — brew cask install iterm2

    Post Install

    • Run iTerm2 then make it the default Terminal
    • Install iTerm2 shell integration and utilities and update ~/.bashrc with tmux export
    curl -L https://iterm2.com/shell_integration/install_shell_integration_and_utilities.sh | bash
    
    cat << 'EOF' >> ~/.bashrc
    # Enable iTerm2 Shell Integrations
    export ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX=1
    test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
    EOF
    • Change default profile: 160x48, Solarized Dark, Fira Code 14pt Regular (use ligatures, anti-aliased), Terminal.app compatibility
    • Additional key mapping changes may be required for natural editing (like keyboard shortcuts for cursor movement in Terminal and vim)
    ⌥← # Send escape sequence b
    ⌥→ # Send escape sequence f
    ⌘←Delete # Send hex code 0x15
    ⌥←Delete # Send hex code 0x1b 0x7f
    Del→ # Send hex code 0x4-
    ⌥Del→ # Send escape sequence d

Bash and Command Line Binaries

  • Bash v5

    • brew install bash

    Post Install

    # Switch to using brew-installed bash as default shell
    if ! fgrep -q '/usr/local/bin/bash' /etc/shells; then
      echo '/usr/local/bin/bash' | sudo tee -a /etc/shells;
      chsh -s /usr/local/bin/bash;
    fi;
    • echo $BASH_VERSION
  • Set default language and source imports

    cat << 'EOF' >> ~/.bashrc
    # Set Language
    export LANG="en_US.UTF-8"
    export LC_ALL="$LANG"
    
    # Imports
    test -e "${HOME}/.secrets" && source "${HOME}/.secrets"
    EOF
  • Set default editors

    cat << 'EOF' >> ~/.bashrc
    # Set default editors
    export EDITOR="$(which vim)"
    export VISUAL="$EDITOR"
    
    # Set editors for Git and Homebrew
    export GIT_EDITOR="$EDITOR"
    export HOMEBREW_EDITOR="$EDITOR"
    EOF
  • Bash Completion

    • brew install bash-completion@2

    Post Install

    cat << 'EOF' >> ~/.bashrc
    # Enable bash tab completion
    export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"
    [[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
    EOF
  • Bash Static Analysis, Linting, and Testing

Command Line Binaries

Replace and augment MacOS default binaries

  • brew install vim --with-override-system-vi --with-python3

  • brew install coreutils

    Post Install coreutils (optional, will cause warning from brew doctor)

    # All commands have been installed with the prefix 'g'.
    # If you really need to use these commands with their normal names:
    
    cat << 'EOF' >> ~/.bashrc
    # Set local opt coreutils bin $PATH
    export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
    EOF
  • brew install curl

    Post Install curl

    cat << 'EOF' >> ~/.bashrc
    # Set local opt curl bin $PATH
    export PATH="/usr/local/opt/curl/bin:$PATH"
    EOF
  • brew install diffutils

  • brew install findutils
    or — brew install findutils --with-default-names
    (optional, will cause warning from brew doctor)

  • brew install gawk

  • brew install gnu-sed --with-default-names

  • brew install gnu-tar --with-default-names

  • brew install gnu-which --with-default-names

  • brew install gnutls

  • brew install grep --with-default-names

  • brew install gzip

  • brew install htop

  • brew install openssh --with-ldns

  • brew install rsync

  • brew install screen

  • brew install tmux

  • brew install tree

  • brew install watch

  • brew install wdiff

  • brew install wget

    Post Install command line binaries

    cat << 'EOF' >> ~/.bashrc
    # Set local system bin $PATH
    export PATH="$PATH:/usr/local/sbin"
    EOF

Additional command line binaries

  • brew install nmapnmap — network mapper

  • brew install youtube-dlyoutube-dl

  • brew cask install emacsemacs

    Post Install emacs (optional)

  • brew install pandocpandoc

  • brew install basictexbasictex

    Post Install pandoc and basictex

    sudo tlmgr update --self
    sudo tlmgr install collection-fontsrecommended

Additional command line binaries, dependencies, and packages

Git

  • brew install git

  • brew install git-lfs && git lfs install

    Post Install

    git config --global user.name "Corey Gouker"
    git config --global user.email [email protected]
    git config --global user.signingkey F8189720240A11D1
    git config --global github.user coreygo
    git config --global core.editor vim
    git config --global color.ui auto
    git config --global commit.gpgsign true
    git config --global credential.helper osxkeychain

    Additional Post Install

    cat << 'EOF' >> ~/.secrets
    # Set GitHub's hub user and access token
    # https://github.com/settings/tokens
    export GITHUB_USER=coreygo
    export GITHUB_TOKEN=
    EOF

Applications

Google

Web, Security, Communications

Development

  • Visual Studio Code

    • brew cask install visual-studio-code-insiders
      or for non-Insiders build — brew cask install visual-studio-code

    Post Install Visual Studio Code — Insiders (extensions list and settings information)

    • To reinstall all extensions from a terminal
      curl -fsSL https://git.io/fjpD1 | bash
  • JetBrains Toolbox

    • brew cask install jetbrains-toolbox
  • Eclipse IDE

    • brew cask install eclipse-installer
  • Postman

    • brew cask install postman
  • VirtualBox
    (requires KEXT - System Preferences → Security & Privacy → General)

    • brew cask install virtualbox
    • brew cask install virtualbox-extension-pack
  • Docker

    Post Install (using stable or edge Docker Desktop for Mac)

    etc=/Applications/Docker.app/Contents/Resources/etc
    ln -s $etc/docker.bash-completion $(brew --prefix)/etc/bash_completion.d/docker
    ln -s $etc/docker-machine.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-machine
    ln -s $etc/docker-compose.bash-completion $(brew --prefix)/etc/bash_completion.d/docker-compose
    • or if not using the "Docker Desktop for Mac" app (VirtualBox based install, not using the HyperKit hypervisor) consider installation using the non-cask formulae, details for this option have not been provided or tested
  • Kubernetes — (k8s docs)

    Post Install (via edge release of Docker Desktop for Mac)

    • Docker → Preferences → Kubernetes → check all three boxes to enable → Apply
    • For kubectl bash completion kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
  • Helm

    • brew install kubernetes-helm
  • Skaffold

    • brew install skaffold
  • Vagrant

    • brew cask install vagrant
  • Packer

    • brew install packer
  • Terraform

    • brew install terraform
  • Zeit Now

    • brew cask install now
  • dnsmasq

    • brew install dnsmasq

    Post Install

    # Backup example dnsmasq.conf
    cp $(brew --prefix)/etc/dnsmasq.conf $(brew --prefix)/etc/dnsmasq.conf.example
    # Create and enable dnsmasq.d configuration directory
    mkdir -p $(brew --prefix)/etc/dnsmasq.d
    echo -e "\n# Include all files in a directory which end in .conf\nconf-dir=/usr/local/etc/dnsmasq.d/,-.conf" >> $(brew --prefix)/etc/dnsmasq.conf
    # Create and enable configuration(s)
    # Networking Note: 10.254.254.254 for Docker/K8s support, otherwise 127.0.0.1
    echo -e "address=/.lo/fdff::1\naddress=/.lo/10.254.254.254" >> $(brew --prefix)/etc/dnsmasq.d/lo.conf
    echo -e "address=/local.coreygo.dev/fdff::1\naddress=/local.coreygo.dev/10.254.254.254" >> $(brew --prefix)/etc/dnsmasq.d/local.coreygo.dev.conf
    # Start dnsmasq with launchd now and restart at startup
    sudo brew services start dnsmasq
    # Create and enable DNS resolver(s) for dnsmasq
    sudo mkdir -p /etc/resolver
    sudo bash -c 'echo -e "nameserver ::1\nnameserver 127.0.0.1" >> /etc/resolver/lo'
    sudo bash -c 'echo -e "nameserver ::1\nnameserver 127.0.0.1" >> /etc/resolver/local.coreygo.dev'
    • Create persistent lo0 alias
    cat << 'EOF' | sudo tee -a /Library/LaunchDaemons/com.coreygo.lo0.plist
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Label</key>
        <string>com.coreygo.lo0</string>
        <key>RunAtLoad</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
          <string>bash</string>
          <string>-c</string>
          <string>/sbin/ifconfig lo0 alias 10.254.254.254 &amp;&amp; /sbin/ifconfig lo0 inet6 alias fdff::1</string>
        </array>
    </dict>
    </plist>
    EOF
    • Enable the launchd service to activate persistent lo0 alias
      sudo launchctl load /Library/LaunchDaemons/com.coreygo.lo0.plist

System, Utilities, Other Applications

Media Streaming and Production

  • Open Broadcaster Software
    • brew cask install obs

    Post Install

  • Soundflower
    for loopback audio from desktop output (requires KEXT - System Preferences → Security & Privacy → General)
    • brew cask install soundflower
  • Avidemux
    • brew cask install avidemux
  • Kap
    • brew cask install kap

Audio/Video Playback and Management

  • VLC
    • brew cask install vlc
  • Plexamp
    • brew cask install plexamp
  • MusicBrainz Picard
    • brew cask install musicbrainz-picard

    Post Install

    • brew install flac mp3gain
    • MusicBrainz Picard Preferences → Plugins → Install ReplayGain → Enable → Make It So
    • Path to metaflac /usr/local/bin/metaflac
    • Path to mp3gain /usr/local/bin/mp3gain
  • XLD
    • brew cask install xld

eBook Management

Adobe

  • Adobe Creative Cloud
    • brew cask install adobe-creative-cloud

    Post Install

    • open '/usr/local/Caskroom/adobe-creative-cloud/latest/Creative Cloud Installer.app'

Gaming

  • Steam
    • brew cask install steam
  • OpenEMU
    • brew cask install openemu

Evernote

Conferencing and Remote Computing

Programming Environments

Node.js & TypeScript

  • Node Version Manager

    export NVM_DIR="$HOME/.nvm" && (
      git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
      cd "$NVM_DIR"
      git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
    ) && \. "$NVM_DIR/nvm.sh"

    Post Install

    cat << 'EOF' >> ~/.bashrc
    # Enable Node Version Manager
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    EOF
    • source ~/.bashrc or restart terminal session

    NVM Default Global Packages

    cat << 'EOF' >> "$NVM_DIR/default-packages"
    create-react-app
    eslint
    gatsby-cli
    gulp-cli
    netlify-cli
    npm
    npm-check
    prettier
    terser
    tslint
    typescript
    EOF

    NVM Manual Upgrade

    (
      cd "$NVM_DIR"
      git fetch --tags origin
      git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
    ) && \. "$NVM_DIR/nvm.sh"
  • Node.js — via NVM

    • nvm install lts/* for latest active LTS Node or for a specific version nvm install v10.16.3
    • nvm install lts/* --reinstall-packages-from=node install latest active LTS Node and reinstall packages from current Node
    • nvm version-remote lts/- display latest available LTS Node version
    • nvm ls-remote --lts list latest available LTS Node versions
    • nvm install node --reinstall-packages-from=node install latest non-LTS Node and reinstall packages from current Node

    Global Node.js Packages

    • npm i -g eslint npm npm-check prettier terser tslint typescript
    • npm ls -g --depth=0 display top level global packages
    • nvm_npm_global_modules $(nvm current) display top level global packages via NVM
    • npm-check -gu check for and/or install latest global packages

    Additional Global Node.js Packages

    • npm i -g create-react-app gatsby-cli gulp-cli netlify-cli

    Yarn Package Manager

    • brew install yarn note, will currently brew install node as a dependency

Python

  • Python — review additional details prior to installing Python via Homebrew to avoid potential issues.

    • brew install python
      or/and for Python 2 — brew install python@2

    Post Install (optional, will supersede system Python and python@2)

    cat << 'EOF' >> ~/.bashrc
    # Set Python 3 $PATH
    export PATH="/usr/local/opt/python/libexec/bin:$PATH"
    EOF
  • pipenv

    • brew install pipenv

    Post Install for pipenv

    cat << 'EOF' >> ~/.bashrc
    # Set Python 3 pipenv to create .venv in project path  
    export PIPENV_VENV_IN_PROJECT=true
    EOF
    • mkdir -p {{project name}} && cd "$_" to create a new Python project directory and pipenv install to create a new pipfile and virtualenv then pipenv shell to activate the virtualenv, you are now ready to pip3 install {{package name}} (use pip3 to avoid issues), and remember to deactivate the shell with exit
    • See pipenv --help or go here for advanced usage details
    • If Python 2 is required for pipenv and virtualenv usage brew install python@2, for a Python 2 project pipenv install --two, remember to review the Python via Homebrew link above before installing Python 2

Ruby

  • Ruby — via rbenv, also review here for Rails and additional information

    • brew install rbenv

    Post Install

    • rbenv init
    cat << 'EOF' >> ~/.bashrc
    # Enable rbenv Ruby environment manager
    if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi # This loads rbenv
    EOF
    • source ~/.bashrc or restart terminal session
    • rbenv --version
    • curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
    • rbenv install 2.6.3 or to list available versions rbenv install -l
    • rbenv global 2.6.3 or to get current active version rbenv global
    • ruby -v
    • gem env for RubyGems environment details
    • gem env home check the location where gems are being installed
    • gem outdated and gem update --force
    • gem cleanup
    • gem install bundler

Go

  • Go

    • brew install go

    Post Install

    cat << 'EOF' >> ~/.bashrc
    # Go Language
    export PATH="$PATH:/usr/local/opt/go/libexec/bin"
    EOF
    • source ~/.bashrc or restart terminal session
    • brew install dep
    • brew install gox

Java

Processing

SDKs & CLIs

  • Google Cloud SDK

    • brew cask install google-cloud-sdk

    Post Install

    cat << 'EOF' >> ~/.bashrc
    # Enable Google Cloud SDK
    test -e "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc" && source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"
    test -e "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc" && source "/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc"
    EOF
  • AWS CLI & Python SDK — first follow steps above to install Python 3 including pipenv via Homebrew

    • cd ~ && mkdir -p .aws && cd "$_" && pipenv install awscli boto3 && pipenv run aws --version
    • cd ~/.aws && pipenv run aws --version to confirm the AWS CLI version, for help see pipenv run aws help
    • or run a command like aws configure after activating the shell cd ~/.aws && pipenv shell remember to exit
  • Azure CLI

    • brew install azure-cli
    • az login
    • az help

Hardware

Wacom Intuos Tablet

  • brew cask install wacom-tablet

OpenBCI

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