Skip to content

Instantly share code, notes, and snippets.

@tmbtech
Forked from nickytonline/my-mac-setup.sh
Created February 15, 2019 00:21
Show Gist options
  • Save tmbtech/38971a7adc764155d722f3648803c4be to your computer and use it in GitHub Desktop.
Save tmbtech/38971a7adc764155d722f3648803c4be to your computer and use it in GitHub Desktop.
Mac Setup Scripts
#!/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=("dark-mode" "git" "gpg" "postgresql" "pyenv" "rbenv")
# List of applications to install via brew cask
declare -a brewCaskApps=("alfred" "brave" "docker" "dropbox" "firefox-developer-edition" "fish" "figma" "flux" "font-fira-code" "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
# 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
beginInstallation "nvm (Node version management)" | tee -a $logFile
export NVM_DIR="$HOME/.nvm"
if [ $reinstall=true ]; then
echo "Uninstalling nvm before reinstalling n." | tee -a $logFile
[ -d $NVM_DIR ] && rm -rf $NVM_DIR | tee -a $logFile
fi
mkdir $NVM_DIR
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash | tee -a $logFile
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
echo "Installing LTS version of node."
nvm install --lts
beginInstallation "Installing global node packages" | tee -a $logFile
npm i -g "${globalNodePackages[@]}" | tee -a $logFile
installComplete "Finished installing global node packages." | 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
# Install Fisherman
beginInstallation "Fisherman" | tee -a $logFile
curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs https://git.io/fisher | tee -a $logFile
installComplete "Fisherman" | 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
# Check to see if fish shell is already a defined shell
echo "Making fish your default shell" | tee -a $logFile
if grep -Fxq "/usr/local/bin/fish" /etc/shells
then
echo "Fish is already defined in the list of available shells." | tee -a $logFile
else
echo /usr/local/bin/fish | sudo tee -a /etc/shells | tee -a $logFile
fi
chsh -s /usr/local/bin/fish | tee -a $logFile
echo "Fish shell is now the default shell. Logout and log back in for it to take effect." | tee -a $logFile
echo "\n\n\n"
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."
fish
set -U fish_user_paths $NVM_DIR fish_user_paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment