Skip to content

Instantly share code, notes, and snippets.

@sascha-egerer
Forked from manuelselbach/setup.sh
Last active October 24, 2018 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sascha-egerer/d663541330282000d814bfec240e7cb8 to your computer and use it in GitHub Desktop.
Save sascha-egerer/d663541330282000d814bfec240e7cb8 to your computer and use it in GitHub Desktop.
Install script for my personal tool chain (Mac OS)
#!/bin/bash
set -e
# insert a line to a file if the line does not already exist
# - first parameter is the file to insert the line
# - second parameter is the line to insert. It'll only be inserted if not already exists
# - third parameter is optional. This will override the search behavior.
# Instead of searching for the line of parameter 2 this term is used.
function insertLineIfNotExists {
FILE=$1
LINE=$2
SEARCH_FOR=${3:-"$LINE"}
touch $FILE
grep -qF "$SEARCH_FOR" "$FILE" || echo "$LINE" >> "$FILE"
}
# config files
bashConfig=~/.bash_profile
sshConfig=~/.ssh/config
##### SSH
# enable autoloading of ssh keys for macOS Sierra
if [ ! -f $sshConfig ]; then
mkdir -p "`dirname \"$sshConfig\"`" 2>/dev/null
touch $sshConfig
fi
# Adjust SSH config
insertLineIfNotExists $sshConfig "AddKeysToAgent yes"
insertLineIfNotExists $sshConfig "UseKeychain yes"
# Adjust bash config
touch $bashConfig
grep -qF "Custom bash config" "$bashConfig" || echo -e "
# Custom bash config
export HOMEBREW_CASK_OPTS=\"$HOMEBREW_CASK_OPTS --appdir=/Applications\"
export VISUAL=\"subl -n -w\"
export EDITOR=\$VISUAL
# Path to the bash it configuration
export BASH_IT=\"/Users/sascha/.bash_it\"
export BASH_IT_THEME=\"iterate\"
# Dont check mail when opening terminal
unset MAILCHECK
export SCM_CHECK=true
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
" >> $bashConfig
# Install Xcode cli tools
xcode-select --install || true
####################
# 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
brew tap caskroom/versions
####################
# Update homebrew recipes
brew update
binaries=(
ack
tree
git
dnsmasq
wget
thefuck
mas
bash-completion
php72
)
echo "[+] installing binaries ..."
brew install ${binaries[@]}
echo "[+] configure dnsmasq to use *.localdev -> 127.0.0.1 as wildcard for local development ..."
cd $(brew --prefix); mkdir -p etc; echo 'address=/.localdev/127.0.0.1' > etc/dnsmasq.conf
sudo cp -v $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo mkdir -p /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/localdev'
cd -
echo "[+] cleaning up brew ..."
brew cleanup
# Install apps from Mac Appstore
macApps=(
497799835 #Xcode
557168941 #Tweetbot
)
echo "[+] installing apps from mac appstore (you have to be logged in to your iCloud account!) ..."
mas install ${macApps[@]}
mas upgrade
# Apps
apps=(
firefox-developer-edition
google-chrome
iterm2
sublime-text
virtualbox
setapp
jetbrains-toolbox
slack
sequel-pro
skype-for-business
1password
imageoptim
docker
dropbox
handbrake
launchbar
teamviewer
)
# Install apps to /Applications
# Default is: /Users/$user/Applications
echo "[+] installing apps ..."
brew cask install ${apps[@]}
# Install Quicklook features
quicklookFeatures=(
qlcolorcode
quicklook-json
qlprettypatch
qlstephen
qlmarkdown
quicklook-csv
qlrest
qlimagesize
webpquicklook
suspicious-package
)
echo "[+] install quicklook features ..."
brew cask install ${quicklookFeatures[@]}
####################
# Mac Default settings
echo "[+] set mac defaults ..."
# miniturize on double click
defaults write -g AppleMiniaturizeOnDoubleClick -int 0
# enable select and copy text within quicklook
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
# Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12
# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 1
# Disable window animations ("new window" scale effect)
# defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
# Turn on dashboard-as-overlay
defaults write com.apple.dashboard enabled-state 3
# Use plain text mode for new TextEdit documents
defaults write com.apple.TextEdit RichText -int 0
# Make bottom-right hotspot start screensaver
defaults write com.apple.dock wvous-br-corner -int 5 && \
defaults write com.apple.dock wvous-br-modifier -int 0
# Make top-left hotspot show desktop
defaults write com.apple.dock wvous-bl-corner -int 4 && \
defaults write com.apple.dock wvous-bl-modifier -int 0
# Make top-right hotspot show notification center
defaults write com.apple.dock wvous-tr-corner -int 12 && \
defaults write com.apple.dock wvous-tr-modifier -int 0
# Tune the Dock
defaults write com.apple.dock autohide -int 1
defaults write com.apple.dock autohide-time-modifier -float 0.7
defaults write com.apple.dock magnification -int 1
defaults write com.apple.dock mineffect -string "genie"
defaults write com.apple.dock minimize-to-application -int 0
defaults write com.apple.dock showhidden -int 0
defaults write com.apple.dock tilesize -int 42
defaults write com.apple.dock position-immutable -int 0
# Enable window dragging with 3 fingers
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -int 1
# Set default Finder location to home folder (~/)
defaults write com.apple.finder NewWindowTarget -string "PfLo" && \
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
# Disable ext change warning
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
# Use current directory as default search scope in Finder
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Show Path bar in Finder
defaults write com.apple.finder ShowPathbar -bool true
# Show Status bar in Finder
defaults write com.apple.finder ShowStatusBar -bool true
# Avoid creating .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Enable the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true && \
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 && \
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
# Show the ~/Library folder
chflags nohidden ~/Library
# Show absolute path in finder's title bar.
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
# Enable AirDrop over Ethernet and on unsupported Macs
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
killall Finder
killall Dock
if [ ! -d ~/.bash_it ]; then
git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
~/.bash_it/install.sh
fi
source ~/.bash_profile
bash-it update
bash-it enable plugin git osx
reload
# activate special chars for git
git config --global core.precomposeunicode true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment