Skip to content

Instantly share code, notes, and snippets.

@DylanTackoor
Last active September 13, 2017 23:58
Show Gist options
  • Save DylanTackoor/972de76f467be12d597299e5c23d1678 to your computer and use it in GitHub Desktop.
Save DylanTackoor/972de76f467be12d597299e5c23d1678 to your computer and use it in GitHub Desktop.
carlos.sh
#!/bin/bash
clear
echo "===================="
echo " macOS SETUP SCRIPT "
echo "===================="
echo ""
sudo -v
# Keep sudo alive
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Keeping Mac awake for one hour
caffeinate -d 3600 &
echo "Installing Brew and command-line tools..."
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew analytics off
echo "Closing System Preferences if open..."
osascript -e 'tell application "System Preferences" to quit'
# Capturing info for later
echo "Full name:"
read fullName
echo "Phone Number (XXX-XXX-XXX):"
read phoneNumber
echo "Contact Email:"
read contactEmail
echo "Apple ID Email:"
read appleIDemail
echo "Apple ID Password:"
read appleIDpassword
echo "Enabling charging toggle sound..."
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true; open /System/Library/CoreServices/PowerChime.app &
echo "Syncing time..."
sudo ntpdate -u time.apple.com
echo "Enabling Safari developer options..."
defaults write com.apple.Safari IncludeDevelopMenu -bool true && \
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true && \
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true && \
defaults write -g WebKitDeveloperExtras -bool true
echo "Dimming hidden Dock icons..."
defaults write com.apple.Dock showhidden -bool YES && killall Dock
echo "Disabling Gatekeeper..."
sudo spctl --master-disable
spctl --status
echo "Setting lockscreen message..."
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "This Mac belongs to $fullName. Contact at $phoneNumber or $contactEmail"
echo "Enabling tap to click for this user & login screen..."
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
echo "Enabling dark mode..."
defaults write /Library/Preferences/.GlobalPreferences.plist _HIEnableThemeSwitchHotKey -bool true
echo "Upping bluetooth audio quality..."
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Max (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Apple Initial Bitpool Min (editable)" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Max" 80
defaults write com.apple.BluetoothAudioAgent "Negotiated Bitpool Min" 80
sudo killall coreaudiod
echo "Autohiding dock..."
defaults write com.apple.dock autohide -bool true && killall Dock
echo "Expanding save panel by default..."
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
echo "Disabling automatically rearranging spaces..."
defaults write com.apple.dock mru-spaces -bool false
echo "Enabling Airdrop over ethernet..."
defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1
echo "Require password immediately after sleep..."
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo "Enabling Ctrl + scroll to zoom screen..."
defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true
defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144
echo "Disabling Dashboard..."
defaults write com.apple.dashboard mcx-disabled -bool true
defaults write com.apple.dock dashboard-in-overlay -bool true
echo "Activity monitor showing stats in dock..."
defaults write com.apple.ActivityMonitor IconType -int 5
echo "Sorting Activity Monitor results by CPU usage..."
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage"
defaults write com.apple.ActivityMonitor SortDirection -int 0
echo "Column view by default..."
defaults write com.apple.Finder FXPreferredViewStyle clmv
echo "Enabling copy emails as plaintext from Mail.app..."
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
echo "Allowing text-selection in Quick Look"
defaults write com.apple.finder QLEnableTextSelection -bool true
echo "Speeding up key repeat..."
defaults write -g KeyRepeat -int 0
echo "Searching current dir by default..."
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
echo "Avoiding creation of .DS_Store files on network or USB volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
echo "Disabling HDD motion sensor protection..."
sudo pmset -a sms 0
echo "Starting iCal on Monday..."
defaults write com.apple.iCal "first day of week" -int 1
echo "Enabling \"Do Not Track\" on Safari..."
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true
echo "Disabling parental controls on guest user..."
sudo dscl . -mcxdelete /Users/guest
sudo rm -rf /Library/Managed\ Preferences/guest
echo "Disabling opening application prompt..."
defaults write com.apple.LaunchServices LSQuarantine -bool false
echo "Disabling file extension editing warning..."
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
echo "Keeping folders on top of file views..."
defaults write com.apple.finder _FXSortFoldersFirst -bool true
echo "Enabling autoupdates for Safari extensions..."
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true
echo "Changing screenshot location..."
defaults write com.apple.screencapture location ~/Pictures/Screenshots/ && killall SystemUIServer
echo "Enabling daily autoupdates..."
defaults write com.apple.commerce AutoUpdate -bool true
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
echo "Updating system..."
softwareupdate -l && sudo softwareupdate -i
echo "Installing command-line applications..."
brew install cask # Install GUI applications
brew install mas # Mac App Store CLI
echo "Signing into Mac App Store..."
mas signin $appleIDemail "$appleIDpassword"
echo "Updating Mac App Store apps..."
mas upgrade
echo "Installing cask apps..."
brew cask install 1password # Best password manager
brew cask install appcleaner # More throughrouly deletes apps
brew cask install battle-net
brew cask install bootchamp
brew cask install caffeine # Menubar icon toggling computer sleep
brew cask install flux
brew cask install google-chrome
brew cask install google-backup-and-sync # New Google Drive client
brew cask install mailbutler
brew cask install microsoft-office
brew cask install monolingual # removes unneeded languages
brew cask install steam
brew cask install teamviewer # Cross platform remote desktop
brew cask install the-unarchiver #
brew cask install transmission # Best Mac/Linux client
brew cask install spotify
brew cask install spotifree
brew cask install whatsapp
brew cask install onyx # Computer diagnostic tool
brew cask install atom # Text editor that can be super useful
echo "Installing quicklook plugins..."
brew cask install qladdict # Subtitle srt files
brew cask install qlcolorcode # Syntax highlighted sourcecode
brew cask install qlvideo
brew cask install quicklook-csv
brew cask install quicklook-json
brew cask install qlstephen
brew cask install qlmarkdown
# brew cask install qlprettypatch
brew cask install qlimagesize # Displays image size in preview
brew cask install betterzipql
brew cask install webpquicklook # Google's Webp image format
brew cask install provisionql
brew cask install quicklookapk
echo "Swapping Chrome print dialogue to expanded native dialogue..."
defaults write com.google.Chrome DisablePrintPreview -bool true
defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true
echo "Configuring transmission..."
mkdir ~/Downloads/Torrenting
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true # Use `~/Downloads/Torrenting` to store incomplete downloads
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Torrenting"
defaults write org.m0k.transmission DownloadAsk -bool false # Don’t prompt for confirmation before downloading
defaults write org.m0k.transmission MagnetOpenAsk -bool false
defaults write org.m0k.transmission DeleteOriginalTorrent -bool true # Trash original torrent files
defaults write org.m0k.transmission WarningDonate -bool false # Hide donate message
defaults write org.m0k.transmission WarningLegal -bool false # Hide legal disclaimer
# Blocks bad IPs & updates list automatically
defaults write org.m0k.transmission BlocklistNew -bool true
defaults write org.m0k.transmission BlocklistURL -string "http://john.bitsurge.net/public/biglist.p2p.gz"
defaults write org.m0k.transmission BlocklistAutoUpdate -bool true
echo "Cleaning up Brew..."
brew cask cleanup
brew update; brew upgrade; brew prune; brew cleanup; brew doctor
# TODO: confirm this is useful
echo "Cleaning up Garage Band..."
sudo rm -rf /Applications/GarageBand
sudo rm -rf /Library/Application Support/GarageBand
sudo rm -rf /Library/Audio/Apple Loops/Apple/Apple\ Loops\ for\ GarageBand
sudo rm -rf /Library/Receipts/com.apple.pkg.GarageBand_AppStore.bom
sudo rm -rf /Library/Receipts/com.apple.pkg.GarageBand_AppStore.plist
sudo rm -rf /System/Library/Receipts/com.apple.pkg.MAContent10_AssetPack_0325_AppleLoopsGarageBand1.bom
sudo rm -rf /System/Library/Receipts/com.apple.pkg.MAContent10_AssetPack_0325_AppleLoopsGarageBand1.plist
sudo rm -rf ~/Library/Application Scripts/com.apple.STMExtension.GarageBand
sudo rm -rf ~/library/Containers/com.apple.STMExtension.GarageBand
echo "Cleaning up Office..."
sudo rm -rf /Applications/Microsoft\ Outlook.app
echo "Alphabetizing Launchpad..."
defaults write com.apple.dock ResetLaunchPad -bool true; killall Dock
echo "Defaulting to Google Chrome..."
open -a "Google Chrome" --args --make-default-browser
echo ""
echo "===================="
echo " THAT'S ALL, FOLKS! "
echo "===================="
echo ""
function reboot() {
read -p "Do you want to reboot your computer now? (y/N)" choice
case "$choice" in
y | Yes | yes ) echo "Yes"; exit;; # If y | yes, reboot
n | N | No | no) echo "No"; exit;; # If n | no, exit
* ) echo "Invalid answer. Enter \"y/yes\" or \"N/no\"" && return;;
esac
}
# Call on the function
if [[ "Yes" == $(reboot) ]]
then
echo "Rebooting."
sudo reboot
exit 0
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment