Skip to content

Instantly share code, notes, and snippets.

@mimosa
Created September 15, 2016 14:12
Show Gist options
  • Save mimosa/fcd0cfbbc74e6414756a56a34c44f1a5 to your computer and use it in GitHub Desktop.
Save mimosa/fcd0cfbbc74e6414756a56a34c44f1a5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# by Benjamin Crozat <benjamin@croz.at>
# https://benjamincrozat.com
#
# Inspired by Mathias Bynens' .macos file.
# https://github.com/mathiasbynens/dotfiles/blob/master/.macos
#
# Not entirely tested yet. Does not fully work on macOS Sierra
###############
###############
###############
###############
# Sudo access #
###############
###############
###############
###############
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
##################
##################
##################
##################
# macOS defaults #
##################
##################
##################
##################
#################
# Miscellaneous #
#################
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "
# Disable smart quotes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable smart dashes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
# Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
# Enable AirDrop over Ethernet and on unsupported Macs running Lion
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
# Enable the MacBook Air SuperDrive on any Mac
sudo nvram boot-args="mbasd=1"
# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
##########
# AppKit #
##########
# Increase window resize speed for Cocoa applications
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
##########
# Finder #
##########
# Set sidebar icon size to small
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 1
# 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
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Remove duplicates in the “Open With” menu (also see `lscleanup` alias)
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# Set Help Viewer windows to non-floating mode
defaults write com.apple.helpviewer DevMode -bool true
# Disable the sudden motion sensor as it’s not useful for SSDs
sudo pmset -a sms 0
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -float 0.000000000001
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
###########
# Menu bar #
###########
# Reveal IP address, hostname, OS version, etc. when clicking the clock
# in the login window
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
##########
# Finder #
##########
# 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
# Enable subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Finder: disable window animations and Get Info animations
defaults write com.apple.finder DisableAllAnimations -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
# Display full POSIX path as Finder window title
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
# When performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Disable the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Show the ~/Library folder
chflags nohidden ~/Library
# Show the /Volumes folder
sudo chflags nohidden /Volumes
# 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
########
# Dock #
########
# Speed up Mission Control animations
defaults write com.apple.dock expose-animation-duration -float 0.1
# Group windows by application in Mission Control
defaults write com.apple.dock expose-group-by-app -bool true
# Remove the auto-hiding Dock delay
defaults write com.apple.dock autohide-delay -float 0
# Remove the animation when hiding/showing the Dock
defaults write com.apple.dock autohide-time-modifier -float 0
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
#############
# LaunchPad #
#############
# Add iOS & Watch Simulator to Launchpad
sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/Simulator.app"
sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator (Watch).app" "/Applications/Simulator (Watch).app"
##########
# Safari #
##########
# Privacy: don’t send search queries to Apple
defaults write com.apple.Safari UniversalSearchEnabled -bool false
defaults write com.apple.Safari SuppressSearchSuggestions -bool true
# Press Tab to highlight each item on a web page
defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true
# Show the full URL in the address bar (note: this still hides the scheme)
defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true
# Prevent Safari from opening ‘safe’ files automatically after downloading
defaults write com.apple.Safari AutoOpenSafeDownloads -bool false
# 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
# Enable Safari’s debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -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
# Enable “Do Not Track”
defaults write com.apple.Safari SendDoNotTrackHTTPHeader -bool true
# Update extensions automatically
defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true
########
# Mail #
########
# Disable send and reply animations in Mail.app
defaults write com.apple.mail DisableReplyAnimations -bool true
defaults write com.apple.mail DisableSendAnimations -bool true
############
# Terminal #
############
# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4
################
# Time Machine #
################
# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
#################
# Mac App Store #
#################
# Enable the WebKit Developer Tools in the Mac App Store
defaults write com.apple.appstore WebKitDeveloperExtras -bool true
# Enable Debug Menu in the Mac App Store
defaults write com.apple.appstore ShowDebugMenu -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
# Install System data files & security updates
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
# Automatically download apps purchased on other Macs
defaults write com.apple.SoftwareUpdate ConfigDataInstall -int 1
# Turn on app auto-update
defaults write com.apple.commerce AutoUpdate -bool true
# Allow the App Store to reboot machine on macOS updates
defaults write com.apple.commerce AutoUpdateRestartRequired -bool true
##########
# Photos #
##########
# Prevent Photos from opening automatically when devices are plugged in
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
############
# Messages #
############
# Disable automatic emoji substitution (i.e. use plain text smileys)
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false
# Disable smart quotes as it’s annoying for messages that contain code
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
killall Finder Dock
################
################
################
################
# Apps & Tools #
################
################
################
################
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew upgrade
# Alternative versions for Homebrew Cask
brew tap caskroom/versions
# Non-Mac App Store apps
brew cask install \
1password \
adobe-creative-cloud \
adobe-photoshop-cc \
adobe-photoshop-lightroom \
air-video-server-hd \
appcleaner \
archiver \
atom \
beamer \
capture-one \
dolphin \
dropbox \
firefox \
gemini \
gfxcardstatus \
google-chrome \
imageoptim \
istat-menus \
java \
openemu \
opera \
paw \
poedit \
qbserve \
rightfont \
sequel-pro \
sizeup \
sketch \
skype \
slack \
sublime-text-dev \
tower \
transmission \
transmit \
unrarx \
vlc
whatsapp \
wwdc \
# Make Sublime Text available through command line as "subl"
ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl
# CLI tools
brew install \
cairo \
ffmpeg \
giflibbrew \
homebrew/php/php70 \
homebrew/php/php70-intl \
homebrew/php/php70-xdebug \
jpeg \
libpng \
mariadb \
mas \
node \
node \
pkg-config \
rbenv \
ruby-build \
wget
# Mac App Store apps:
# - 1Blocker
# - Calcbot
# - Tweetbot
# - Twitter
# - Icon Slate
# - Screens VNC
# - Dash
# - Xcode
# - Frank DeLoupe
# - Reeder
# - Gaget
mas install \
1025729002 \
376694347 \
376694347 \
409789998 \
439697913 \
446107677 \
449589707 \
497799835 \
530458789 \
697846300 \
968487158
###################
# ~/.bash_profile #
###################
# Folder where I store code
mkdir ~/Code
# Useful variables
echo "export EDITOR=\"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl\"" >> ~/.bash_profile
echo "export PS1=\"\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ \"" >> ~/.bash_profile
echo "export CLICOLOR=1" >> ~/.bash_profile
echo "export LSCOLORS=ExFxBxDxCxegedabagacad" >> ~/.bash_profile
echo "export PATH=\"$PATH:$HOME/.composer/vendor/bin\"" >> ~/.bash_profile
echo "if which ruby >/dev/null && which gem >/dev/null; then PATH=\"$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH\"; fi" >> ~/.bash_profile
echo "if which rbenv > /dev/null; then eval \"$(rbenv init -)\"; fi" >> ~/.bash_profile
# Cool aliases I use daily
echo "alias bp=\"subl ~/.bash_profile\"" >> ~/.bash_profile
echo "alias crontab=\"EDITOR=pico crontab\"" >> ~/.bash_profile
echo "alias hidehidden=\"defaults write com.apple.finder AppleShowAllFiles -boolean false && killall Finder\"" >> ~/.bash_profile
echo "alias kdock=\"killall Dock\"" >> ~/.bash_profile
echo "alias repos=\"cd ~/Code\"" >> ~/.bash_profile
echo "alias rmdnscache=\"dscacheutil -flushcache && sudo killall -HUP mDNSResponder\"" >> ~/.bash_profile
echo "alias rmtrash=\"rm -rf ~/.Trash/*\"" >> ~/.bash_profile
echo "alias rstlaunch=\"defaults write com.apple.dock ResetLaunchPad -bool true && killall Dock\"" >> ~/.bash_profile
echo "alias showhidden=\"defaults write com.apple.finder AppleShowAllFiles -boolean true && killall Finder\"" >> ~/.bash_profile
source ~/.bash_profile
##############
# ~/.forward #
##############
echo "benjamin@croz.at" >> ~/.forward
############
# Composer #
############
wget https://getcomposer.org/installer -o composer-installer.php
php composer-installer.php
rm composer-installer.php
mv composer.phar /usr/local/bin/composer
###########
# Laravel #
###########
composer global require laravel/installer laravel/valet
valet install
###########
# Symfony #
###########
curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
chmod a+x /usr/local/bin/symfony
###########
# node.js #
###########
npm install -g gulp bower grunt-cli peerflix vue-cli
#############
# Ruby GEMs #
#############
rbenv install 2.3.1
rbenv global 2.3.1
sudo gem update --system
gem install cocoapods --user-install
#######
# SSH #
#######
# I need to generate a public SSH key for various uses.
ssh-keygen -t rsa
# That's all folks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment