-
-
Save jamesmhaley/c3690e0aea625b2a711cebb22f58610a to your computer and use it in GitHub Desktop.
This file contains 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 | |
# To execute: save and `chmod +x ./brew-install-script.sh` then `./brew-install-script.sh` | |
echo "------------------------------------------------------------------------------------" | |
echo "Mac setup initialised. Please make sure you change the settings before running this." | |
echo "Any questions, ask James." | |
echo " " | |
echo "WARNING:" | |
echo "Do not run this script on an existing Mac as it changes a lot and may kill your installation". | |
echo "------------------------------------------------------------------------------------" | |
# Close any open System Preferences panes, to prevent them from overriding | |
# settings we’re about to change | |
osascript -e 'tell application "System Preferences" to quit' | |
# Ask for the administrator password upfront | |
sudo -v | |
echo "ENVIRONMENT SETUP" | |
# Switch off "natural" scrolling | |
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false | |
# Disable the sound effects on boot | |
sudo nvram SystemAudioVolume=" " | |
# Expand save panel by default | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true | |
# Expand print panel by default | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true | |
# Disable Resume system-wide | |
defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false | |
# Disable hibernation (speeds up entering sleep mode) | |
sudo pmset -a hibernatemode 0 | |
# Increase sound quality for Bluetooth headphones/headsets | |
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 | |
# Require password immediately after sleep or screen saver begins | |
defaults write com.apple.screensaver askForPassword -int 1 | |
defaults write com.apple.screensaver askForPasswordDelay -int 0 | |
# Save screenshots to the desktop | |
defaults write com.apple.screencapture location -string "${HOME}/Desktop" | |
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) | |
defaults write com.apple.screencapture type -string "png" | |
# Finder: show hidden files by default | |
defaults write com.apple.finder AppleShowAllFiles -bool true | |
# Finder: show all filename extensions | |
defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
# Finder: show status bar | |
defaults write com.apple.finder ShowStatusBar -bool true | |
# Finder: show path bar | |
defaults write com.apple.finder ShowPathbar -bool true | |
# Keep folders on top when sorting by name | |
defaults write com.apple.finder _FXSortFoldersFirst -bool true | |
# Enable spring loading for directories | |
defaults write NSGlobalDomain com.apple.springing.enabled -bool true | |
# Avoid creating .DS_Store files on network or USB volumes | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true | |
# Disable the warning before emptying the Trash | |
defaults write com.apple.finder WarnOnEmptyTrash -bool false | |
# Show the ~/Library folder | |
chflags nohidden ~/Library | |
# Expand the following File Info panes: | |
# “General”, “Open with”, and “Sharing & Permissions” | |
defaults write com.apple.finder FXInfoPanesExpanded -dict \ | |
General -bool true \ | |
OpenWith -bool true \ | |
Privileges -bool true | |
# Enable spring loading for all Dock items | |
defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true | |
# Show indicator lights for open applications in the Dock | |
defaults write com.apple.dock show-process-indicators -bool true | |
# Disable Dashboard | |
defaults write com.apple.dashboard mcx-disabled -bool true | |
# Don’t show Dashboard as a Space | |
defaults write com.apple.dock dashboard-in-overlay -bool true | |
# Don’t automatically rearrange Spaces based on most recent use | |
defaults write com.apple.dock mru-spaces -bool false | |
# Remove the auto-hiding Dock delay | |
defaults write com.apple.dock autohide-delay -float 0 | |
# Automatically hide and show the Dock | |
defaults write com.apple.dock autohide -bool true | |
# Bottom left screen corner → Sleep Display | |
defaults write com.apple.dock wvous-bl-corner -int 10 | |
defaults write com.apple.dock wvous-bl-modifier -int 0 | |
# Show Safari’s bookmarks bar by default | |
defaults write com.apple.Safari ShowFavoritesBar -bool true | |
# Enable the Develop menu and the Web Inspector in Safari | |
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 | |
# Add a context menu item for showing the Web Inspector in web views | |
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true | |
# Copy email addresses as `[email protected]` instead of `Foo Bar <[email protected]>` in Mail.app | |
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false | |
# Use a modified version of the Solarized Dark theme by default in Terminal.app | |
#set Terminal defaults | |
sudo -u $USER defaults write /Users/$USER/Library/Preferences/com.apple.Terminal.plist "Default Window Settings" "Homebrew" | |
sudo -u $USER defaults write /Users/$USER/Library/Preferences/com.apple.Terminal.plist "Startup Window Settings" "Homebrew" | |
#set window width to 120 | |
sudo /usr/libexec/PlistBuddy -c "Add :Window\ Settings:Homebrew:columnCount integer 120" /Users/$USER/Library/Preferences/com.apple.Terminal.plist | |
defaults write /Users/$USER/Library/Preferences/com.apple.Terminal.plist "NSWindow Frame TTWindow Homebrew" "97 302 1075 366 0 0 1280 777 " | |
# Show the main window when launching Activity Monitor | |
defaults write com.apple.ActivityMonitor OpenMainWindow -bool true | |
# Visualize CPU usage in the Activity Monitor Dock icon | |
defaults write com.apple.ActivityMonitor IconType -int 5 | |
# Show all processes in Activity Monitor | |
defaults write com.apple.ActivityMonitor ShowCategory -int 0 | |
# Sort Activity Monitor results by CPU usage | |
defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" | |
defaults write com.apple.ActivityMonitor SortDirection -int 0 | |
# Enable the WebKit Developer Tools in the Mac App Store | |
defaults write com.apple.appstore WebKitDeveloperExtras -bool true | |
# Enable the automatic update check | |
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true | |
# Check for software updates daily, not just once per week | |
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 | |
# Download newly available updates in background | |
defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1 | |
# Prevent Photos from opening automatically when devices are plugged in | |
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true | |
# Use the system-native print preview dialog | |
defaults write com.google.Chrome DisablePrintPreview -bool true | |
defaults write com.google.Chrome.canary DisablePrintPreview -bool true | |
# Expand the print dialog by default | |
defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true | |
defaults write com.google.Chrome.canary PMPrintingExpandedStateForPrint2 -bool true | |
# Homebrew Script for OSX | |
# To execute: save and `chmod +x ./brew-install-script.sh` then `./brew-install-script.sh` | |
echo "ALIAS SETUP" | |
cat <<EOT >> ~/.custom-alias | |
# Easier navigation: .., ..., ...., ....., ~ and - | |
alias ..="cd .." | |
alias ...="cd ../.." | |
alias ....="cd ../../.." | |
alias .....="cd ../../../.." | |
# GIT | |
alias g="git" | |
# Detect which ls flavor is in use | |
if ls --color > /dev/null 2>&1; then # GNU `ls` | |
colorflag="--color" | |
export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:' | |
else # macOS `ls` | |
colorflag="-G" | |
export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx' | |
fi | |
# List all files colorized in long format | |
alias l="ls -lF ${colorflag}" | |
# List all files colorized in long format, including dot files | |
alias la="ls -laF ${colorflag}" | |
# List only directories | |
alias lsd="ls -lF ${colorflag} | grep --color=never '^d'" | |
# Always use color output for ls | |
alias ls="command ls ${colorflag}" | |
# Enable aliases to be sudo’ed | |
alias sudo='sudo ' | |
# Google Chrome | |
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome' | |
# Lock the screen (when going AFK) | |
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" | |
# Print each PATH entry on a separate line | |
alias path='echo -e ${PATH//:/\\n}' | |
# Create a new directory and enter it | |
function mkd() { | |
mkdir -p "$@" && cd "$_"; | |
} | |
# o with no arguments opens the current directory, otherwise opens the given | |
# location | |
function o() { | |
if [ $# -eq 0 ]; then | |
open .; | |
else | |
open "$@"; | |
fi; | |
} | |
EOT | |
cat <<EOT >> ~/.profile | |
# IMPORT OUR NEW ALIAS FILE | |
source ~/.custom-alias | |
EOT | |
echo "TECH SETUP" | |
echo "Install Oh My Zsh" | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
echo "Installing brew..." | |
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
brew update | |
echo "Installing brew cask..." | |
brew tap caskroom/cask | |
#Programming Languages | |
brew install node | |
brew install yarn | |
#DB | |
brew install mongodb | |
#Dev Tools | |
brew install git | |
brew install n | |
breq install docker | |
brew cask install visual-studio-code | |
brew cask install postman | |
#Communication Apps | |
brew cask install slack | |
brew cask install whatsapp | |
#Others | |
brew install mas | |
brew cask install spotify | |
brew cask install flycut | |
#Mac AppStore Apps (use `mas list`, to list on a mac that has what you need installed) | |
#Below all require licences | |
mas install 451444120 # Memory Clean | |
mas install 441258766 # Magnet | |
mas install 1091189122 # Bear | |
mas install 404705039 # Graphic | |
mas install 407963104 # Pixelmator | |
# vscode settings | |
code --install-extension Shan.code-settings-sync | |
# Cleanup | |
brew cleanup | |
brew cask cleanup | |
# Wipe all (default) app icons from the Dock | |
# This is only really useful when setting up a new Mac, or if you don’t use | |
# the Dock to launch apps. | |
defaults write com.apple.dock persistent-apps -array | |
# Add icons to the dock | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Launchpad.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Safari.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Google Chrome.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Calendar.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Notes.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Mail.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Messages.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Slack.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Visual Studio Code.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Utilities/Terminal.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Postman.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/App Store.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/System Preferences.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' | |
# Close everything | |
for app in "Activity Monitor" \ | |
"Address Book" \ | |
"Calendar" \ | |
"cfprefsd" \ | |
"Contacts" \ | |
"Dock" \ | |
"Finder" \ | |
"Google Chrome Canary" \ | |
"Google Chrome" \ | |
"Mail" \ | |
"Messages" \ | |
"Photos" \ | |
"Safari" \ | |
"SystemUIServer"; do | |
killall "${app}" &> /dev/null | |
done | |
echo " /(| " | |
echo " ( : " | |
echo " __\ \ _____ " | |
echo " (____) \| " | |
echo " (____)| | " | |
echo " (____).__| " | |
echo " (___)__.|_____ " | |
echo " " | |
echo "Everything is done, now restart Terminal..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment