Skip to content

Instantly share code, notes, and snippets.

@luzlab
Last active December 6, 2021 19:29
Show Gist options
  • Save luzlab/acdd0a519a30629412ff896d403d1606 to your computer and use it in GitHub Desktop.
Save luzlab/acdd0a519a30629412ff896d403d1606 to your computer and use it in GitHub Desktop.
Mac Developer Setup
# Inspired by https://gist.github.com/kevinelliott/7a152c556a83b322e0a8cd2df128235c
##############################################################################
# Install brew and base set of packages
##############################################################################
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# might need to run `sudo chown -R $USER:admin /usr/local` if install fails because of permissions issue.
brew update && brew upgrade
brew install zsh docker docker-machine docker-compose git wget jq coreutils curl binutils kafkacat bfg gitversion pkg-config cairo libffi grep gnu-sed gnu-tar
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
gsed -i '1i\PATH=$HOME/bin:/usr/local/bin:/usr/local/opt/curl/bin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:$PATH' $HOME/.zshrc
touch .zshenv
gsed -i '1i\PATH=$HOME/bin:/usr/local/bin:/usr/local/opt/curl/bin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/opt/gnu-tar/libexec/gnubin:$PATH' $HOME/.zshenv
echo 'MANPATH=/usr/local/opt/grep/libexec/gnuman:/usr/local/opt/coreutils/libexec/gnuman:/usr/local/opt/gnu-sed/libexec/gnuman:/usr/local/opt/gnu-tar/libexec/gnuman:$MANPATH' >> $HOME/.zshrc
alias ll="gls -la --color=tty"
alias l='gls --color=tty -lah'
alias la='gls --color=tty -lAh'
alias ll='gls --color=tty -la'
alias ls='gls --color=tty'
alias lsa='gls --color=tty -lah'
mkdir $HOME/bin
ln -s `which gdircolors` $HOME/bin/dircolors
### QUIT AND RELAUNCH TERMINAL ###
##############################################################################
# Configure zsh
##############################################################################
# plugins https://github.com/unixorn/awesome-zsh-plugins
# ! zsh-syntax must be the last plugin - https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git for git aliases
# see https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/meteor for meteor aliases
sed -i "s|^plugins.*|plugins=(git osx docker zsh-iterm-touchbar node npm meteor history zsh-dircolors-solarized las-dir brew sudo ssh-agent wd per-directory-history zsh-syntax)|gm" $HOME/.zshrc
# https://medium.com/the-code-review/powerlevel9k-personalise-your-prompt-for-any-programming-language-68974c127c63
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
sed -i 's|robbyrussell|powerlevel10k/powerlevel10k|' $HOME/.zshrc
sed -i "1iPOWERLEVEL9K_MODE='nerdfont-complete'" $HOME/.zshrc
echo "POWERLEVEL9K_PROMPT_ON_NEWLINE=true" >> $HOME/.zshrc
echo "DEFAULT_USER=`whoami`" >> $HOME/.zshrc
sed -i 's/# export SSH_KEY_PATH/export SSH_KEY_PATH/' $HOME/.zshrc
# see https://github.com/robbyrussell/oh-my-zsh/wiki/Plugin:git for git aliases
# see https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/meteor for meteor aliases
git clone --recursive git://github.com/joel-porquet/zsh-dircolors-solarized $ZSH_CUSTOM/plugins/zsh-dircolors-solarized
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
##############################################################################
# Shell Configuration
##############################################################################
### QUIT AND RELAUNCH TERMINAL ###
echo "TERM=xterm-256color” >> $HOME/.zshrc
setupsolarized dircolors.256dark
echo 'export HISTSIZE=50000' >> $HOME/.zshrc # How many lines of history to keep in memory
echo 'export HISTFILE=~/.zsh_history' >> $HOME/.zshrc # Where to save history to disk
echo 'export SAVEHIST=50000' >> $HOME/.zshrc # Number of history entries to save to disk
echo '#export HISTDUP=erase' >> $HOME/.zshrc # Erase duplicates in the history file
echo 'setopt appendhistory' >> $HOME/.zshrc # Append history to the history file (no overwriting)
echo 'setopt sharehistory' >> $HOME/.zshrc # Share history across terminals
echo 'setopt incappendhistory' >> $HOME/.zshrc # Immediately append to the history file, not just when a term is killed
# colorize the output of `ls`
curl https://raw.githubusercontent.com/seebi/dircolors-solarized/master/dircolors.ansi-dark > $HOME/.dircolors
# curl https://raw.github.com/trapd00r/LS_COLORS/master/LS_COLORS > $HOME/.dircolors # another color scheme
echo 'eval $(dircolors -b $HOME/.dircolors)' >> $HOME/.zshrc
# command aliases and other customizations
#echo 'alias XX="XXX"' >> $HOME/.zshrc
#alias nvm-meteor="nvm install \`meteor node -v\` && npm install --global npm@\`meteor npm -v\`"
echo "alias draw.io=/Applications/draw.io.app/Contents/MacOS/draw.io" >> ~/.zshrc
echo 'alias diff=colordiff' >> $HOME/.zshrc
##############################################################################
# QUIT AND REOPEN YOUR SHELL AT THIS POINT
##############################################################################
##############################################################################
# Install apps
##############################################################################
brew install dropbox drawio vmware-fusion gpg-suite 1password visual-studio-code iterm2 sourcetree postman p4v dash
open /Applications/Dropbox.app # login and sync your home folder
# brew cask install sketch
# Brew cask install psequel
ln -s /Applications/p4merge.app/Contents/Resources/launchp4merge /usr/local/bin/p4merge
##############################################################################
# Install AppStore apps
##############################################################################
brew install mas
# Make sure you've signed into the App Store with your iCloud account
mas install `mas search "remote desktop" | grep -oP '[0-9]*?(?=\s+Microsoft Remote Desktop)'`
# Brew now installs the Xcode CLI tools so it's not necessary to download xcode anymore
# mas install `mas search xcode | grep -oP '[0-9]*?(?=\s+Xcode)'`
# sudo xcodebuild -license # accept the license for Xcode
# xcode-select --install
##############################################################################
# set p4merge as default merge tool
##############################################################################
git config --global merge.tool /usr/local/bin/p4merge
# git config --global mergetool.p4mergetool.cmd \
# "/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED”
git config --global mergetool.p4merge.trustExitCode true
git config --global mergetool.keepBackup true
git config --global mergetool.keepTemporaries true
git config --global mergetool.prompt true
##############################################################################
# set p4merge as default diff tool
##############################################################################
git config --global diff.tool /usr/local/bin/p4merge
# git config --global difftool.p4mergetool.cmd \
# "/Applications/p4merge.app/Contents/Resources/launchp4merge \$LOCAL \$REMOTE"
##############################################################################
# Improve git diffs
##############################################################################
git config --global diff.compactionHeuristic 1
# git config --global pager.log "`brew --prefix`/bin/colordiff | less"
# git config --global pager.show "`brew --prefix`/bin/colordiff | less"
# git config --global pager.diff "`brew --prefix`/bin/colordiff | less"
# git config --global interactive.diffFilter "`brew --prefix`/bin/colordiff"
# https://www.viget.com/articles/dress-up-your-git-diffs-with-word-level-highlights/
# https://michaelheap.com/git-and-diff-highlight/
##############################################################################
# Misc git configs
##############################################################################
git config --global user.name "Carlo Quinonez"
git config --global user.email "carlo.quinonez@thermofisher.com"
git config --global core.editor "code -n -w --disable-extensions"
git config --global color.ui true
git config --global core.excludesfile ~/.gitignore_global
##############################################################################
# Set default editors for brew
##############################################################################
echo 'export HOMEBREW_EDITOR=code' >> $HOME/.zshrc
echo 'export VISUAL=code' >> $HOME/.zshrc
##############################################################################
# Install drivers
##############################################################################
brew tap caskroom/drivers
brew cask install ftdi-vcp-driver
##############################################################################
# Install fonts
##############################################################################
brew tap homebrew/cask-fonts
brew install font-inconsolata
# power line fonts for zsh command prompt
brew install font-consolas-for-powerline
brew install font-fira-mono-for-powerline
wget https://raw.githubusercontent.com/ryanoasis/nerd-fonts/6c6ef8ef0ca382efbd39bd709007e6ee8f64edbf/patched-fonts/PragmataPro%20for%20Powerline%20Plus%20Nerd%20File%20Types.ttf
curl -L https://iterm2.com/shell_integration/install_shell_integration_and_utilities.sh | bash
https://github.com/ryanoasis/nerd-fonts/blob/6c6ef8ef0ca382efbd39bd709007e6ee8f64edbf/patched-fonts/PragmataPro%20for%20Powerline%20Plus%20Nerd%20File%20Types.ttf
##############################################################################
# Docker-machine
##############################################################################
# you'll have to first open VMWare Fusion and enter license info
docker-machine create --driver=vmwarefusion linux
# if the above command fails, try recovering using "docker-machine regenerate-certs linux"
brew services start docker-machine # set to start at login
echo 'eval "$(docker-machine env linux)"' >> $HOME/.zshrc
# the following adapted from http://cavaliercoder.com/blog/update-etc-hosts-for-docker-machine.html
#echo 'export DOCKER_IP="$(echo ${DOCKER_HOST} | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')"' >> $HOME/.zshrc
echo ‘export DOCKER_IP=`docker-machine ip linux`’ >> $HOME/.zshrc
echo 'if grep -q "$DOCKER_IP" /etc/hosts; then' >> $HOME/.zshrc
echo ' echo "Entry for docker.local at IP $DOCKER_IP found in /etc/host"' >> $HOME/.zshrc
echo 'else' >> $HOME/.zshrc
echo ' echo "Need admin privleges to add entry '$DOCKER_IP docker.local' to /etc/host"' >> $HOME/.zshrc
echo ' sudo sed -i “/[[:space:]]docker\.local$/d” /etc/hosts' >> $HOME/.zshrc
echo ' [[ -n $DOCKER_IP ]] && echo "${DOCKER_IP} docker.local" | sudo tee -a /etc/hosts' >> $HOME/.zshrc
echo 'fi' >> $HOME/.zshrc
##############################################################################
# Node Application development
##############################################################################
curl https://install.meteor.com/ | sh # install meteor
PROFILE='.zshrc' wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# check to make sure NVM version is recent.
echo 'export NODE_ENV="development"' >> $HOME/.zshrc # Set the default NODE_ENV to development
##############################################################################
# Ruby Application development
##############################################################################
wget -qO- https://get.rvm.io | bash -s stable --ruby
echo 'source /Users/carlo.quinonez/.rvm/scripts/rvm' >> $HOME/.zshrc
##############################################################################
# Azure DevOps and Development
##############################################################################
brew install azure-cli microsoft-azure-storage-explorer
##############################################################################
# Misc development dependancies
##############################################################################
npm install -g node-gyp eslint prettier commitizen powerbi-visuals-tools json-to-plantuml lerna yarn
brew install awscli
echo 'source /usr/local/etc/bash_completion.d/az' >> $HOME/.zshrc
curl -L https://iterm2.com/shell_integration/install_shell_integration_and_utilities.sh | bash
echo 'export PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig' >> $HOME/.zshenv
echo 'export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/readline/lib/pkgconfig' >> $HOME/.zshenv
##############################################################################
# Misc MacOS configs
##############################################################################
chflags nohidden ~/Library # Show the ~/Library folder
mkdir ~/Screenshots # Store screenshots in subfolder on desktop
defaults write com.apple.screencapture location ~/Screenshots
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true # Add a context menu item for showing the Web Inspector in web views

defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
defaults write com.apple.Notes SmartQuotes -bool false # Turn off smart quotes in Notes
defaults write com.apple.Notes SmartDashes -bool false # Turn off smart dashes in Notes
sudo spctl --master-disable # allow apps from anywhere to run (restores "anywhere" option in system prefs)
sudo sed -i '2iauth sufficient pam_tid.so' /etc/pam.d/sudo # enable Touch Bar for sudo!
# Fix preferences in iTerm2->Preferences > Advanced > (Goto the Session heading) > Allow sessions to survive logging out and back in.
# By default, word jumps (option + → or ←) and word deletions (option + backspace) do not work. To enable these, go to "iTerm → # Preferences → Profiles → Keys → Presets... → Natural Text Editing
# sudo nvram boot # Boot into versbose mode
##############################################################################
# SSH Keys and Other Credentials
##############################################################################
ssh-keygen -t rsa -m PEM -C "MacBook Air"
# the "-m PEM" option ensure the keys are as compatible as possible. Azure Key Vault won't accept them otherwise.
#####################################################
# Windows VM for development
##############################################################################
# Go to and download the ISO for the latest version of Windows 10
open https://www.microsoft.com/en-us/software-download/windows10ISO
#### DOCKER HACK https://github.com/machine-drivers/docker-machine-driver-vmware/issues/15
echo 'export PATH=$PATH:$(go env GOPATH)/bin' >> .zshrc
echo 'export GOPATH=$(go env GOPATH)' >> .zshrc
# exit and reopen shell
go get -u github.com/machine-drivers/docker-machine-driver-vmware
docker-machine -D create -d vmware --vmware-boot2docker-url=https://github.com/StefanScherer/boot2docker/releases/download/18.09.0-vmware/boot2docker.iso default
@luzlab
Copy link
Author

luzlab commented Dec 6, 2021

sadf

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