Last active
October 26, 2018 15:54
-
-
Save chaoslogick/b864e083c4c8057e05dd to your computer and use it in GitHub Desktop.
BASH: Personal setup.sh for OSX
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/bash | |
# Alot of these configs have been taken from the various places | |
# on the web | |
# Set the colors you can use | |
black='\033[0;30m' | |
white='\033[0;37m' | |
red='\033[0;31m' | |
green='\033[0;32m' | |
yellow='\033[0;33m' | |
blue='\033[0;34m' | |
magenta='\033[0;35m' | |
cyan='\033[0;36m' | |
# Resets the style | |
reset=`tput sgr0` | |
# arg $1 = message | |
# arg $2 = Color | |
cecho() { | |
echo "${2}${1}${reset}" | |
return | |
} | |
# Set continue to false by default | |
CONTINUE=false | |
echo "" | |
cecho "Have you read through the script you're about to run and " $red | |
cecho "understood that it will make changes to your computer? (y/n)" $red | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
CONTINUE=true | |
fi | |
if ! $CONTINUE; then | |
# Check if we're continuing and output a message if not | |
cecho "Please go read the script, it only takes a few minutes." $red | |
exit | |
fi | |
# Ask for the administrator password upfront. | |
sudo -v | |
cecho "*** Root access granted ***" $red | |
# 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 & | |
# Install command-line tools using Homebrew. | |
echo "" | |
echo "Installing Xcode..." | |
xcode-select install | |
sudo xcodebuild -license | |
# Install homebrew (Xcode CLI tools required) | |
if test ! $(which brew); then | |
echo "" | |
echo "Installing homebrew..." | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
fi | |
# Make sure we’re using the latest Homebrew. | |
brew update | |
# Upgrade any already-installed formulae. | |
brew upgrade | |
# Install GNU core utilities (those that come with OS X are outdated). | |
# Don’t forget to add `$(brew --prefix coreutils)/libexec/gnubin` to `$PATH`. | |
brew install coreutils | |
ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum | |
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed | |
brew install findutils | |
# Install Bash 4 | |
brew install bash | |
brew install bash-completion | |
# Switch to new bash version from OSX default | |
# Don't forget to add `/usr/local/bin/bash` to `/etc/shells` | |
chsh -u $USER -s $(brew --prefix)/bin/bash | |
# Install `wget` with IRI support. | |
brew install wget --with-iri | |
# Install more recent versions of some OS X tools. | |
brew tap homebrew/dupes | |
brew tap homebrew/versions | |
brew install vim --override-system-vi | |
brew install homebrew/dupes/grep | |
brew install homebrew/dupes/openssh | |
brew install homebrew/dupes/screen | |
# Install caskroom | |
brew tap caskroom/fonts | |
brew tap caskroom/versions | |
brew install caskroom/cask/brew-cask | |
# Deprecated, install manually | |
#brew install caskroom/cask/xquartz | |
#brew install caskroom/cask/java | |
# Install system binaries | |
brew_sys=( | |
ack | |
autoconf | |
axel | |
cairo | |
curl | |
htop | |
gnu-sed | |
libtool | |
pv | |
rename | |
tree | |
watch | |
zsh | |
) | |
echo "" | |
echo "Installing development binaries..." | |
brew install ${brew_sys[@]} | |
# Install development binaries | |
brew_dev=( | |
automake | |
awscli | |
binutils | |
boost | |
cmake | |
cscope | |
eigen | |
emacs | |
ffmpeg | |
gcc | |
git | |
gist | |
git-crypt | |
heroku-toolbelt | |
lua | |
macvim | |
markdown | |
msgpack # For neovim | |
mysql | |
nginx | |
node | |
nvm | |
#phantomjs # Not compiling in El Capitan | |
postgresql | |
pow | |
purescript | |
python | |
python3 | |
qt | |
rbenv | |
rbenv-gem-rehash | |
redis | |
rhino | |
scons # For neovim | |
swig | |
texi2html | |
the_silver_searcher | |
vcsh | |
) | |
echo "" | |
echo "Installing development binaries..." | |
brew install ${brew_dev[@]} | |
# Install security binaries | |
brew_sec=( | |
aircrack-ng | |
bcrypt | |
cifer | |
dns2tcp | |
ettercap | |
fcrackzip | |
hashpump | |
hping | |
hydra | |
john | |
knock | |
netcat | |
nettle | |
nmap | |
openssl | |
skipfish | |
socat | |
sqlmap | |
tcpdump | |
tcpflow | |
tcpreplay | |
tcptrace | |
ucspi-tcp # `tcpserver` etc. | |
wireshark | |
) | |
echo "" | |
echo "Installing security binaries..." | |
brew install ${brew_sec[@]} | |
# Install other useful binaries | |
brew_misc=( | |
binwalk | |
cmatrix | |
cowsay | |
exiv2 | |
ffmpeg | |
graphicsmagick | |
graphviz | |
imagemagick --with-webp | |
irssi | |
jpeg | |
lynx | |
mackup | |
p7zip | |
reattach-to-user-namespace | |
speedtest-cli | |
tmux | |
transmission | |
trash | |
unrar | |
xdot | |
youtube-dl | |
zopfli | |
) | |
echo "" | |
echo "Installing misc binaries..." | |
brew install ${brew_misc[@]} | |
# Fix bug in os x terminal backspace implementation | |
infocmp $TERM | sed 's/kbs=^[hH]/kbs=\\177/' > $TERM.ti | |
tic $TERM.ti | |
# Remove outdated versions from the cellar | |
echo "" | |
echo "Cleaning up homebrew cellar..." | |
brew cleanup | |
# Install pip | |
echo "" | |
echo "Installing pip..." | |
easy_install pip | |
pip install --upgrade pip setuptools | |
# Neovim only supports install from head | |
echo "" | |
echo "Installing neovim..." | |
brew tap neovim/neovim | |
brew install neovim --HEAD | |
pip install neovim | |
# Install cask applications | |
cask_apps=( | |
0xed | |
adapter # why? | |
alfred | |
atom | |
bartender | |
charles | |
codekit | |
firefox | |
firefoxdeveloperedition | |
flame | |
google-chrome | |
google-chrome-canary | |
iterm2 | |
kismac | |
mactex | |
macvim | |
navicat-for-postgresql | |
spectacle | |
stay | |
transmission | |
transmit | |
vagrant | |
virtualbox | |
viscosity | |
vivaldi | |
xscope | |
) | |
# Install apps to /Applications | |
# Default is: /Users/$user/Applications | |
echo "" | |
echo "Installing cask applications..." | |
brew cask install --appdir="/Applications" ${cask_apps[@]} | |
# Install cask fonts | |
cask_fonts=( | |
font-anonymous-pro | |
font-anonymous-pro-for-powerline | |
font-droid-sans | |
font-fontawesome | |
font-hack | |
font-inconsolata | |
font-inconsolata-for-powerline | |
font-input | |
font-meslo-lg | |
font-meslo-lg-for-powerline | |
font-roboto | |
font-source-code-pro | |
font-sauce-code-powerline | |
) | |
echo "" | |
echo "Installing cask fonts..." | |
brew cask install ${cask_fonts[@]} | |
echo "" | |
cecho "################################################################################" $white | |
# Set your network hostname | |
echo "" | |
echo "Would you like to set your computer name" | |
echo "(as done via System Preferences > Sharing)? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
echo "What would you like it to be?" | |
read COMPUTER_NAME | |
sudo scutil --set ComputerName $COMPUTER_NAME | |
sudo scutil --set HostName $COMPUTER_NAME | |
sudo scutil --set LocalHostName $COMPUTER_NAME | |
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $COMPUTER_NAME | |
dscacheutil -flushcache | |
fi | |
# Removing duplicates in the 'Open With' menu | |
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user | |
# Show the ~/Library folder in Finder | |
chflags nohidden ~/Library | |
# Hide the /opt folder in Finder | |
chflags hidden /opt | |
# Use Plain Text Mode as Default in Text Edit | |
defaults write com.apple.TextEdit RichText -int 0 | |
# Finder | |
echo "" | |
echo "Show icons for hard drives, servers, and removable media on the desktop? (y/n)" | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true | |
fi | |
echo "" | |
echo "Show hidden files in Finder by default? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.Finder AppleShowAllFiles -bool true | |
fi | |
echo "" | |
echo "Show all filename extensions in Finder by default? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
fi | |
echo "" | |
echo "Show status bar in Finder by default? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.finder ShowStatusBar -bool true | |
fi | |
echo "" | |
echo "Display full POSIX path as Finder window title? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true | |
fi | |
echo "" | |
echo "Avoid creation of .DS_Store files on network volumes? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
fi | |
echo "" | |
echo "Disable disk image verification? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
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 | |
fi | |
# Allowing text selection in Quick Look/Preview in Finder by default | |
defaults write com.apple.finder QLEnableTextSelection -bool true | |
echo "" | |
echo "Show item info near icons on the desktop and in other icon views? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist | |
fi | |
echo "" | |
echo "Show item info to the right of the icons on the desktop? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
/usr/libexec/PlistBuddy -c "Set DesktopViewSettings:IconViewSettings:labelOnBottom false" ~/Library/Preferences/com.apple.finder.plist | |
fi | |
echo "" | |
echo "Enable snap-to-grid for icons on the desktop and in other icon views? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
fi | |
# Increase grid spacing for icons on the desktop and in other icon views? (y/n) | |
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist | |
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 100" ~/Library/Preferences/com.apple.finder.plist | |
echo "" | |
cecho "################################################################################" $white | |
# Dock & Mission Control | |
echo "" | |
echo "Wipe all (default) app icons from the Dock? (y/n)" | |
echo "(This is only really useful when setting up a new Mac, or if you don't use the Dock to launch apps.)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.dock persistent-apps -array | |
fi | |
# Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate | |
defaults write com.apple.dock tilesize -int 36 | |
# Speeding up Mission Control animations and grouping windows by application | |
defaults write com.apple.dock expose-animation-duration -float 0.1 | |
defaults write com.apple.dock "expose-group-by-app" -bool true | |
echo "" | |
echo "Set Dock to auto-hide and remove the auto-hiding delay? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
defaults write com.apple.dock autohide -bool true | |
defaults write com.apple.dock autohide-delay -float 0 | |
defaults write com.apple.dock autohide-time-modifier -float 0.425 | |
fi | |
echo "" | |
cecho "################################################################################" $white | |
# Terminal | |
echo "" | |
echo "Enabling UTF-8 ONLY in Terminal.app and setting the Pro theme by default..." | |
defaults write com.apple.terminal StringEncodings -array 4 | |
defaults write com.apple.Terminal "Default Window Settings" -string "Pro" | |
defaults write com.apple.Terminal "Startup Window Settings" -string "Pro" | |
echo "" | |
cecho "################################################################################" $white | |
# Transmission.app | |
echo "" | |
echo "Do you use Transmission for torrenting? (y/n)" | |
read -r response | |
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
echo "Setting up new Transmission defaults..." | |
# Setting up an incomplete downloads folder in Downloads | |
mkdir -p ~/Downloads/Incomplete | |
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true | |
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete" | |
# Setting auto-add folder to be Downloads | |
defaults write org.m0k.transmission AutoImportDirectory -string "${HOME}/Downloads" | |
# Don't prompt for confirmation before downloading | |
defaults write org.m0k.transmission DownloadAsk -bool false | |
# Trash original torrent files after adding them | |
defaults write org.m0k.transmission DeleteOriginalTorrent -bool true | |
# Hiding the donate message | |
defaults write org.m0k.transmission WarningDonate -bool false | |
# Hiding the legal disclaimer | |
defaults write org.m0k.transmission WarningLegal -bool false | |
# Setting up the block list | |
defaults write org.m0k.transmission EncryptionRequire -bool true | |
defaults write org.m0k.transmission BlocklistAutoUpdate -bool true | |
defaults write org.m0k.transmission BlocklistNew -bool true | |
defaults write org.m0k.transmission BlocklistURL -string "http://john.bitsurge.net/public/biglist.p2p.gz" | |
fi | |
echo "Enable verbose boot..." | |
# Always verbose boot sequence | |
sudo nvram boot-args="-v" | |
# Kill affected applications | |
echo "" | |
cecho "Done!" $cyan | |
echo "" | |
echo "" | |
cecho "################################################################################" $white | |
echo "" | |
echo "" | |
cecho "Note that some of these changes require a logout/restart to take effect." $red | |
cecho "Killing some open applications in order to take effect." $red | |
echo "" | |
find ~/Library/Application\ Support/Dock -name "*.db" -maxdepth 1 -delete | |
for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \ | |
"Dock" "Finder" "Mail" "Messages" "Safari" "SystemUIServer" \ | |
"Terminal" "Transmission"; do | |
killall "${app}" > /dev/null 2>&1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment