Skip to content

Instantly share code, notes, and snippets.

@c3ry5 c3ry5/macsetup.sh
Last active Sep 5, 2019

Embed
What would you like to do?
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Apps
apps=(
java
docker
google-chrome
visual-studio-code
sublime-text
macdown
skype
spectacle
github
charles
spotify
github-desktop
)
# Brews
brews=(
maven
git
git-flow
node
htop
wget
nmap
geoip
awscli
mongo
)
# Gems
gems=(
sass
)
# global npm
globalnpm=(
gulp-cli
nodemon
cordova
electron
babel
localtunnel
yarn
)
if [ -e "/Applications/Xcode.app" ]; then
echo "Xcode installed continuing"
else
echo "Xcode not installed exiting. Download xcode for macos App store https://itunes.apple.com/gb/app/xcode/id497799835?mt=12"
exit 1
fi
if [[ -f ~/.ssh/id_rsa && -f ~/.ssh/id_rsa.pub && !$1 && !$2 ]]; then
echo "key exists"
else
echo "Creating an SSH key for you..."
ssh-keygen -t rsa
sshpub=$(cat ~/.ssh/id_rsa.pub)
curl -v -H "Authorization: token $1" --data '{"title":"'"$2"'","key":"'"$sshpub"'"}' https://api.github.com/user/keys
fi
if test ! $(which xcode-select); then
echo "Installing xcode-stuff"
xcode-select --install
fi
# 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
# Install apps to /Applications
echo "installing apps with Cask..."
for i in "${apps[@]}"
do
brew cask install ${i}
done
echo "Installing utilities"
for i in "${brews[@]}"
do
if test ! $(which i); then
brew install ${i}
fi
done
echo "Cleaning up brew"
brew cleanup
echo "Installing gems"
for i in "${gems[@]}"
do
sudo gem install ${i}
done
echo "Installing Global NPM modules"
for i in "${globalnpm[@]}"
do
npm install ${i} --global
done
brew cleanup
# create symlink
if [ -e "/Applications/Sublime Text.app" ]; then
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime
fi
# Add to bash profile
if grep -Fxq "alias ll='ls -lGaf'" ~/.bash_profile
then
echo "ll already added"
else
echo -e "\nalias ll='ls -lGaf'" >> ~/.bash_profile
fi
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
#"Expanding the save panel by default"
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
#"Automatically quit printer app once the print jobs complete"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
#"Saving to disk (not to iCloud) by default"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
#"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
#"Enabling full keyboard access for all controls (e.g. enable Tab in modal dialogs)"
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
#"Disabling press-and-hold for keys in favor of a key repeat"
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool true
#"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
#"Avoiding the creation of .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
#"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
#"Setting screenshots location to ~/Desktop"
defaults write com.apple.screencapture location -string "$HOME/Desktop"
#"Setting screenshot format to PNG"
defaults write com.apple.screencapture type -string "png"
#"Hiding Safari's bookmarks bar by default"
defaults write com.apple.Safari ShowFavoritesBar -bool false
#"Hiding Safari's sidebar in Top Sites"
defaults write com.apple.Safari ShowSidebarInTopSites -bool false
#"Disabling Safari's thumbnail cache for History and Top Sites"
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
#"Enabling Safari's debug menu"
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
#"Making Safari's search banners default to Contains instead of Starts With"
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false
#"Removing useless icons from Safari's bookmarks bar"
defaults write com.apple.Safari ProxiesInBookmarksBar "()"
#"Allow hitting the Backspace key to go to the previous page in history"
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
#"Enabling 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
#"Adding a context menu item for showing the Web Inspector in web views"
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
#"Disable 'natural' (Lion-style) scrolling"
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
# Don’t automatically rearrange Spaces based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# Show hidden files
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.