-
-
Save rvargs/eb6d18c52a4d38b1e0e9041b503be9e7 to your computer and use it in GitHub Desktop.
Mac Setup Scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# More Mac setup at https://mac.iamdeveloper.com | |
# Log file | |
timestamp=$(date +%s) | |
logFile="./my-mac-setup-$timestamp.log" | |
# if true is passed in, things will reinstall | |
reinstall=$1 | |
beginInstallation() { | |
echo "Starting installation for $1..." | tee -a $logFile | |
} | |
installComplete() { | |
echo "Installation complete for $1.\n\n\n" | tee -a $logFile | |
} | |
# List of applications to install via brew | |
declare -a brewApps=("git" "gpg" "nvm" "postgresql" "pyenv" "rbenv" "rustup" "wget" "zsh" "zplug") | |
# List of applications to install via brew cask | |
declare -a brewCaskApps=("alfred" "brave-browser" "docker" "dropbox" "firefox-developer-edition" "figma" "flux" "font-fira-code" "fork" "google-chrome" "google-chrome-canary" "iterm2" "licecap" "keybase" "ngrok" "nordvpn" "now" "onyx" "microsoft-office" "postgres" "postman" "sketch" "slack" "spectacle" "spotify" "the-unarchiver" "vanilla" "visual-studio-code-insiders" "vlc") | |
# Global node packages to install | |
declare -a globalNodePackages=("npm@latest" "yarn" "yo" "fkill" "alfred-fkill") | |
# List of applications to start right away | |
declare -a appsToStartRightAway=("Alfred 3" "Dropbox" "Flux" "Spectacle" "Vanilla") | |
# Make the auto-hide time to reveal the doc a very large number. | |
echo "Ghetto removal of the Mac dock." | tee -a $logFile | |
defaults write com.apple.dock autohide-time-modifier -int 300; | |
killall Dock; | |
# https://twitter.com/siracusa/status/1004143205078597633 | |
echo "Putting back setting Subpixel antialiasing for text in MacOS Mojave" | tee -a $logFile | |
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO | |
echo "Installing command line tools" | tee -a $logFile | |
xcode-select --install | |
# https://stackoverflow.com/a/26647594/77814 | |
echo "Setting correct permissions on folders that brew needs acccess to." | |
sudo chown -R `whoami`:admin /usr/local/bin | |
sudo chown -R `whoami`:admin /usr/local/share | |
# Install applications | |
echo "Installing applications. You may be prompted at certain points to provide your password." | tee -a $logFile | |
command -v brew >/dev/null 2>&1 || { | |
beginInstallation "Homebrew" | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
installComplete "Homebrew" | |
beginInstallation "Homebrew Cask" | |
brew tap caskroom/cask | |
installComplete "Homebrew Cask" | |
} | tee -a $logFile | |
echo "Setting up some brew tap stuff for fonts and some applications" | tee -a $logFile | |
brew tap caskroom/versions | tee -a $logFile | |
brew tap caskroom/fonts | tee -a $logFile | |
echo "Finished setting up some brew tap stuff for fonts and some applications" | tee -a $logFile | |
for appName in "${brewApps[@]}" | |
do | |
beginInstallation $appName | tee -a $logFile | |
if [ $reinstall=true ]; then | |
brew reinstall $appName | tee -a $logFile | |
else | |
brew install $appName | tee -a $logFile | |
fi | |
installComplete $appName | tee -a $logFile | |
done | |
for appName in "${brewCaskApps[@]}" | |
do | |
beginInstallation $appName | tee -a $logFile | |
if [ $reinstall=true ]; then | |
brew cask reinstall $appName | tee -a $logFile | |
else | |
brew cask install $appName | tee -a $logFile | |
fi | |
installComplete $appName | tee -a $logFile | |
done | |
beginInstallation "Setting up node.js" | tee -a $logFile | |
export NVM_DIR="$HOME/.nvm" | |
mkdir $NVM_DIR | |
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm | |
echo "Installing LTS version of node." | |
nvm install --lts | |
nvm alias default "lts/*" | |
nvm use default | |
installComplete "Finished installing node.js." | tee -a $logFile | |
beginInstallation "Installing global node packages" | tee -a $logFile | |
npm i -g "${globalNodePackages[@]}" | tee -a $logFile | |
installComplete "Finished installing global node packages." | tee -a $logFile | |
echo "Done installing applications" | tee -a $logFile | |
echo "\n\n\n" | tee -a $logFile | |
echo "Just a few final touches..." | tee -a $logFile | |
# Make zsh the default shell | |
echo "Making zsh the default shell" | tee -a $logFile | |
sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh | tee -a $logFile | |
echo which zsh | tee -a $logFile | |
dscl . -read /Users/$USER UserShell | tee -a $logFile | |
echo $SHELL | tee -a $logFile | |
chsh -s $(which zsh) | tee -a $logFile | |
echo "Installing oh-my-zsh" | tee -a $logFile | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | tee -a $logFile | |
echo "Installing some plugins for zsh" | tee -a $logFile | |
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | tee -a $logFile | |
echo "Creating .zshrc file" | tee -a $logFile | |
touch ~/.zshrc | tee -a $logFile | |
echo "export ZPLUG_HOME=/usr/local/opt/zplug | |
export ZPLUG_HOME=/usr/local/opt/zplug | |
export GEM_HOME=$HOME/.gem | |
export NVM_LAZY_LOAD=true | |
export PATH=$HOME/.rbenv/shims:$GEM_HOME/bin:$HOME/.cargo/bin:$PATH | |
export ZSH=$HOME/.oh-my-zsh | |
export NVM_DIR=\"$HOME/.nvm\" | |
[ -s \"/usr/local/opt/nvm/nvm.sh\" ] && . \"/usr/local/opt/nvm/nvm.sh\" # This loads nvm | |
[ -s \"/usr/local/opt/nvm/etc/bash_completion\" ] && . \"/usr/local/opt/nvm/etc/bash_completion\" # This loads nvm bash_completion | |
ZSH_THEME="agnoster" | |
DEFAULT_USER=`whoami` | |
plugins=( | |
git | |
bundler | |
dotenv | |
osx | |
rake | |
rbenv | |
ruby | |
z | |
zsh-autosuggestions | |
) | |
source $ZSH/oh-my-zsh.sh | |
source $ZPLUG_HOME/init.zsh | |
alias rimraf='rm -rf' | |
alias flushdns='sudo killall -HUP mDNSResponder'" > ~/.zshrc | tee -a $logFile | |
echo "Testing zsh prompt" | tee -a $logFile | |
zsh | tee -a $logFile | |
echo "Starting applications that are used for the Desktop" | tee -a $logFile | |
for appName in "${appsToStartRightAway[@]}" | |
do | |
echo "Starting $appName..." | tee -a $logFile | |
open -a "$appName" | tee -a $logFile | |
done | |
echo "A setup log is available at $logFile." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment