Skip to content

Instantly share code, notes, and snippets.

@zengyu714
Forked from bradp/setup.sh
Last active November 30, 2021 02:46
Show Gist options
  • Save zengyu714/35ff771ec575e376dbc68892de1b040c to your computer and use it in GitHub Desktop.
Save zengyu714/35ff771ec575e376dbc68892de1b040c to your computer and use it in GitHub Desktop.
New Mac Setup Script
# echo "Creating an SSH key for you..."
# ssh-keygen -t rsa
# setup github key following https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
echo "Installing xcode-stuff"
xcode-select --install
# Check for Homebrew,
# Install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Update homebrew recipes
echo "Updating homebrew..."
brew update
echo "Installing newer/latest Git evrsion than the default one in /usr/bin/git..."
brew install git
echo "Git config"
git config --global user.name yu
git config --global user.email zykimmy714@gmail.com
echo "Installing brew git utilities..."
# https://frostming.github.io/legit/
brew install legit
# brew install git-flow
# brew install git-extras
echo "Installing other brew stuff..."
brew install tree
brew install fzf
brew install tldr
brew install zsh-autosuggestions
brew install wget
brew install autojump
brew install trash
brew install mackup
brew install node
# Complete the setup of autojump
echo "[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh" >> ~/.zshrc
echo "Cleaning up brew"
brew cleanup
echo "Installing homebrew cask"
brew install homebrew/cask
echo "Restoring dotfiles from iCloud"
printf "\
[storage]
engine = icloud
directory = ConfigBackup
" >> ~/.mackup.cfg
mackup restore
#Install Zsh & Oh My Zsh
echo "Installing Oh My ZSH..."
curl -L http://install.ohmyz.sh | sh
echo "Setting up Zsh plugins..."
cd ~/.oh-my-zsh/custom/plugins
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
echo "Setting ZSH as shell..."
chsh -s /bin/zsh
# Enable vi mode
echo "bindkey -v" >> ~/.zshrc
# Apps
apps=(
dozer
visual-studio-code
google-chrome
iterm2
qlstephen
suspicious-package
stats
# cleanmymac
# cloud
# harvest # Time monitor
# vlc # Media palyer
# transmission # Open-source BitTorrent client
)
# Install apps to /Applications
# Default is: /Users/$user/Applications
echo "installing apps with Cask..."
brew cask install --appdir="/Applications" ${apps[@]}
brew cask cleanup
brew cleanup
echo "Setting some Mac settings..."
#"Allow text selection in Quick Look"
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
#"Disabling OS X Gate Keeper"
#"(You'll be able to install any app you want from here on, not just Mac App Store apps)"
sudo spctl --master-disable
sudo defaults write /var/db/SystemPolicy-prefs.plist enabled -string no
defaults write com.apple.LaunchServices LSQuarantine -bool false
#"Automatically quit printer app once the print jobs complete"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
#"Check for software updates daily, not just once per week"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
#"Disable smart quotes and smart dashes as they are annoying when typing code"
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
#"Showing icons for hard drives, servers, and removable media on the desktop"
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
#"Showing all filename extensions in Finder by default"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
#"Disabling the warning when changing a file extension"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
#"Use column view in all Finder windows by default"
defaults write com.apple.finder FXPreferredViewStyle Clmv
#"Avoiding the creation of .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
#"Enabling snap-to-grid for icons on the desktop and in other icon views"
# /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
# /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
# /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
#"Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate"
# defaults write com.apple.dock tilesize -int 36
#"Speeding up Mission Control animations and grouping windows by application"
# defaults write com.apple.dock expose-animation-duration -float 0.1
# defaults write com.apple.dock "expose-group-by-app" -bool true
#"Setting Dock to auto-hide and removing the auto-hiding delay"
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0
#"Setting email addresses to copy as 'foo@example.com' instead of 'Foo Bar <foo@example.com>' in Mail.app"
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
#"Preventing Time Machine from prompting to use new hard drives as backup volume"
# defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
#"Disable the sudden motion sensor as its not useful for SSDs"
sudo pmset -a sms 0
#"Disable annoying backswipe in Chrome"
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
#"Setting screenshot format to PNG"
# defaults write com.apple.screencapture type -string "png"
#"Don't prompt for confirmation before downloading"
defaults write org.m0k.transmission DownloadAsk -bool false
killall Finder
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment