Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
smitmartijn committed Mar 19, 2019
0 parents commit 09e483f
Show file tree
Hide file tree
Showing 7 changed files with 370 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
@@ -0,0 +1,18 @@
# MacOS Setup Scripts

These scripts complete my MacOS configuration by changing a bunch of MacOS settings (apply_os_settings.sh) and installing my base applications (install_apps.sh) and then configuring a few apps (apply_app_settings.sh).

This is completely catered to my own taste and installs applications that I use. If you're like to use this form of automated install, go over each script and have a look at the settings it configures and the apps that it installs to personalise it to your needs.

These scripts will work on a freshly installed MacOS device. It uses [Homebrew](https://brew.sh) and the [Mac App Store CLI](https://github.com/mas-cli/mas) to install applications.

There's also the directory 'offline-apps/' and the install_apps.sh script runs to all downloaded .pkg files and installs them as well. At the bottom of install_apps.sh is also a list of URLs to DMG files that it will download, mount and detect whether to just move it to /Applications or use the installer cli.

# Steps

sh apply_os_settings.sh
reboot
sh install_apps.sh
reboot
sh apply_app_settings.sh
reboot
6 changes: 6 additions & 0 deletions apply_app_settings.sh
@@ -0,0 +1,6 @@
#! /usr/bin/env bash

# Apply application settings

cp ~/Dropbox/MacOS-Setup/dotfiles/$HOST.bash_profile ~/.bash_profile
cp ~/Dropbox/MacOS-Setup/dotfiles/$HOST.my-zshrc ~/.zshrc
173 changes: 173 additions & 0 deletions apply_os_settings.sh
@@ -0,0 +1,173 @@
#! /usr/bin/env bash

# Apply machine hostname
read -p "What is this machine's label (Example: \"ernie\")? " mac_os_label
if [[ -z "$mac_os_label" ]]; then
printf "ERROR: Invalid MacOS label.\n"
exit 1
fi

read -p "What is this machine's name (Example: \"ernie\")? " mac_os_name
if [[ -z "$mac_os_name" ]]; then
printf "ERROR: Invalid MacOS name.\n"
exit 1
fi

printf "Setting system label and name...\n"
sudo scutil --set ComputerName $mac_os_label
sudo scutil --set HostName $mac_os_name
sudo scutil --set LocalHostName $mac_os_name
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $mac_os_name

printf "Getting rid of enrollment agent..\n"
sudo launchctl remove com.apple.ManagedClientAgent.enrollagent
sudo launchctl unload com.apple.ManagedClientAgent.enrollagent

printf "Disabling guest user..\n"
sudo dscl . -delete /Users/Guest
sudo security delete-generic-password -a Guest -s com.apple.loginwindow.guest-account -D "application password" /Library/Keychains/System.keychain
sudo defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool FALSE

# Applies system and application defaults.

printf "System - Enaling Dark mode\n"
defaults write NSGlobalDomain AppleInterfaceStyle Dark

printf "System - Disable boot sound effects\n"
sudo nvram SystemAudioVolume=" "

printf "System - Expand save panel by default\n"
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true

printf "System - Disable the 'Are you sure you want to open this application?' dialog\n"
defaults write com.apple.LaunchServices LSQuarantine -bool false

printf "System - Disable auto-correct\n"
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

printf "System - Disable smart quotes (not useful when writing code)\n"
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

printf "System - Disable smart dashes (not useful when writing code)\n"
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false

printf "System - Require password immediately after sleep or screen saver begins\n"
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0

printf "System - Hot Corner: Bottom Right - Put display to sleep"
defaults write ~/Library/Preferences/com.apple.dock.plist wvous-br-corner -int 10
defaults write ~/Library/Preferences/com.apple.dock.plist wvous-br-modifier -int 0

printf "System - Avoid creating .DS_Store files on network & USB volumes\n"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

printf "System - Don't chime when power is plugged in\n"
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false

printf "System - Disable autocorrect\n"
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false

printf "System - Disable Bonjour\n"
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array-add "-NoMulticastAdvertisements"

printf "Bluetooth - Increase sound quality for headphones/headsets\n"
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40

printf "Dock - Remove all default app icons\n"
defaults write com.apple.dock persistent-apps -array

printf "Dock - Don't show recently used apps"
defaults write com.apple.dock show-recents -bool false

printf "Dock - Automatically hide and show\n"
defaults write com.apple.dock autohide -bool true

printf "Dock - Remove the auto-hiding delay\n"
defaults write com.apple.dock autohide-delay -float 0

printf "Dock - Title size and magnification\n"
defaults write com.apple.dock magnification -bool true
defaults write com.apple.dock tilesize -int 48
defaults write com.apple.dock largesize -int 64

printf "Dock - Don’t show Dashboard as a Space\n"
defaults write com.apple.dock "dashboard-in-overlay" -bool true

printf "iCloud - Save to disk by default\n"
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false

printf "Finder - Show the $HOME/Library folder\n"
chflags nohidden $HOME/Library

printf "Finder - Show hidden files\n"
defaults write com.apple.finder AppleShowAllFiles -bool true

printf "Finder - Show filename extensions\n"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true

printf "Finder - Disable the warning when changing a file extension\n"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

printf "Finder - Show path bar\n"
defaults write com.apple.finder ShowPathbar -bool true

printf "Finder - Show status bar\n"
defaults write com.apple.finder ShowStatusBar -bool true

printf "Finder - Use list view in all Finder windows\n"
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"

printf "Finder - Allow text selection in Quick Look\n"
defaults write com.apple.finder QLEnableTextSelection -bool true

printf "Safari - Set home page to 'about:blank' for faster loading\n"
defaults write com.apple.Safari HomePage -string "about:blank"

printf "Safari - Use Contains instead of Starts With in search banners\n"
defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false

printf "Safari - Enable debug menu\n"
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true

printf "Safari - Enable the Develop menu and the Web Inspector\n"
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

printf "Safari - Add a context menu item for showing the Web Inspector in web views\n"
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

printf "Safari - Disable sending search queries to Apple.\n"
defaults write com.apple.Safari UniversalSearchEnabled -bool false

printf "Chrome - Prevent native print dialog, use system dialog instead\n"
defaults write com.google.Chrome DisablePrintPreview -boolean true

printf "TextEdit - Use plain text mode for new documents\n"
defaults write com.apple.TextEdit RichText -int 0

printf "TextEdit - Open and save files as UTF-8 encoding\n"
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4

printf "Trackpad - Disable natural scroll\n"
defaults write -g com.apple.swipescrolldirection -bool NO

printf "Printer - Expand print panel by default\n"
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true

printf "Printer - Automatically quit printer app once the print jobs complete\n"
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

printf "Game Center - Disable Game Center\n"
defaults write com.apple.gamed Disabled -bool true

printf "App Store - Enable the WebKit Developer Tools in the Mac App Store\n"
defaults write com.apple.appstore WebKitDeveloperExtras -bool true

printf "App Store - Enable Debug Menu in the Mac App Store\n"
defaults write com.apple.appstore ShowDebugMenu -bool true

printf "You should reboot now\n"
11 changes: 11 additions & 0 deletions dotfiles/pino.bash_profile
@@ -0,0 +1,11 @@

export EDITOR=nano
export PATH="/usr/local/bin:$PATH"

# Display git branch in path
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "


19 changes: 19 additions & 0 deletions dotfiles/pino.my-zshrc
@@ -0,0 +1,19 @@
# Load extensions
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# Activate plugins
plugins=(git zsh-completions)

# Custom paths
PATH=/usr/local/sbin:$PATH

# Custom vars
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

# Set default editor
export EDITOR='nano'

# Theme
ZSH_THEME="fishy"
143 changes: 143 additions & 0 deletions install_apps.sh
@@ -0,0 +1,143 @@
#! /usr/bin/env bash

# Installs Homebrew software.

if ! command -v brew > /dev/null; then
ruby -e "$(curl --location --fail --show-error https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:$PATH"
printf "export PATH=\"/usr/local/bin:$PATH\"\n" >> $HOME/.bash_profile
fi

printf "Updating brew\n"
brew upgrade && brew update

printf "Installing xcode cli utils\n"
xcode-select --install

printf "brew: Installing cli packages\n"
brew install git
brew install gpg
brew install mas # Apple store cli
brew install node # NodeJS dev
brew install openssl # Generate certificates
brew install ruby-install
brew install terraform # Automation
brew install vim # Guilty pleasure
brew install watch
brew install wakeonlan
brew install wget

# Install ZSH and Oh My ZSH
brew install zsh zsh-completions zsh-autosuggestions zsh-syntax-highlighting

chsh -s /usr/local/bin/zsh
/usr/local/bin/zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"


printf "brew: Installing apps\n"
brew cask install 1password
brew cask install 1password-cli
brew cask install bartender
brew cask install dropbox
brew cask install docker
brew cask install evernote
brew cask install firefox
brew cask install franz
brew cask install google-chrome
brew cask install grammarly
brew cask install handbrake
brew cask install istat-menus
brew cask install iterm2
brew cask install java
brew cask install keybase
brew cask install ngrok
brew cask install nordvpn
brew cask install postman
brew cask install powershell
brew cask install slack
brew cask install spotify
brew cask install tor-browser
brew cask install tuxera-ntfs
brew cask install rescuetime
brew cask install royal-tsx
brew cask install visual-studio-code
brew cask install vlc
brew cask install vmware-fusion
brew cask install wireshark
brew cask install wifi-explorer
brew cask install zoomus
brew cask install zoomus-outlook-plugin
brew cask install xmind-zen


# Installs App Store software.

if ! command -v mas > /dev/null; then
printf "ERROR: Mac App Store CLI (mas) can't be found.\n"
printf " Please ensure Homebrew and mas (i.e. brew install mas) have been installed first."
exit 1
fi

printf "AppStore: Installing The Unarchiver\n"
mas install 425424353

printf "AppStore: Installing Todoist\n"
mas install 585829637

printf "AppStore: Installing Tweetbot 3\n"
mas install 1384080005

printf "AppStore: Installing Microsoft Remote Desktop 10\n"
mas install 1295203466

printf "AppStore: Installing Microsoft OneDrive\n"
mas install 823766827

printf "AppStore: Installing Microsoft OneNote\n"
mas install 784801555

printf "AppStore: Installing Microsoft Excel\n"
mas install 462058435

printf "AppStore: Installing Microsoft Outlook\n"
mas install 985367838

printf "AppStore: Installing Microsoft Word\n"
mas install 462054704

printf "AppStore: Installing Microsoft PowerPoint\n"
mas install 462062816

printf "Installing offline apps..\n"
for f in offline-apps/*.pkg ;
do sudo installer -pkg "$f" -target /
done

printf "Downloading and installing apps via .dmg links..\n"
URLs=(
https://download.techsmith.com/camtasiamac/releases/Camtasia.dmg
https://download.techsmith.com/snagitmac/releases/Snagit.dmg
https://download01.logi.com/web/ftp/pub/techsupport/presentation/LogiPresentation_1.52.95.dmg
https://jabraxpressonlineprdstor.blob.core.windows.net/jdo/JabraDirectSetup.dmg
http://files.whatpulse.org/whatpulse-mac-2.8.4.dmg
)

for i in "${URLs[@]}";
do
wget -P ~/Downloads/ "$i"
DMG=$(echo $i | rev | cut -d / -f 1 | rev)
VOL=$(hdiutil attach ~/Downloads/$DMG | grep -i '/Volumes/' | awk -F " " '{print $3}')

if [ -e "$VOL"/*.app ]; then
sudo cp -rf "$VOL"/*.app /Applications/
elif [ -e "$VOL"/*.pkg ]; then
package=$(ls -1 "$VOL" | grep .pkg | head -1)
sudo installer -pkg "$VOL"/"$package" -target /
elif [ -e "$VOL"/*.mpkg ]; then
package=$(ls -1 "$VOL" | grep .mpkg | head -1)
sudo installer -pkg "$VOL"/"$package" -target /
fi

hdiutil unmount "$VOL"
done
Empty file added offline-apps/EMPTY
Empty file.

0 comments on commit 09e483f

Please sign in to comment.