diff --git a/.aliases b/.aliases new file mode 100644 index 0000000..ebdac53 --- /dev/null +++ b/.aliases @@ -0,0 +1,104 @@ +#!/usr/bin/env bash + +# Easier navigation: .., ..., ...., ....., ~ and - +alias ..="cd .." +alias ...="cd ../.." +alias ....="cd ../../.." +alias .....="cd ../../../.." +alias ~="cd ~" # `cd` is probably faster to type though +alias -- -="cd -" + +# Shortcuts +alias d="cd ~/Documents/Dropbox" +alias dl="cd ~/Downloads" +alias dt="cd ~/Desktop" +alias p="cd ~/projects" +alias g="git" + +alias i="itermocil" +alias ls="ls -lash" +alias g="gulp" +alias gw="gulp watch" +alias gs="gulp serve" + +alias rubies="rvm list rubies" +alias gemsets="rvm gemset list" +alias gemset="rvm gemset use" + + +alias rg='rails generate' +alias rgm='rails generate migration' +alias rs='rails server' +alias rdm='rake db:migrate' +alias rdr='rake db:rollback' +alias rdc='rake db:create' +alias rds='rake db:seed' +alias rdd='rake db:drop' +alias rdrs='rake db:reset' +alias dbr='rake db:drop; rake db:create; rake db:migrate; rake db:seed' +alias rr='rake routes' +alias rrg='rake routes | grep' +alias devlog='tail -f log/development.log' +alias prodlog='tail -f log/production.log' +alias testlog='tail -f log/test.log' +alias -g RED='RAILS_ENV=development' +alias -g REP='RAILS_ENV=production' +alias -g RET='RAILS_ENV=test' +alias beg='bundle exec guard' + +# Detect which `ls` flavor is in use +if ls --color > /dev/null 2>&1; then # GNU `ls` + colorflag="--color" + export LS_COLORS='no=00:fi=00:di=01;31:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:' +else # macOS `ls` + colorflag="-G" + export LSCOLORS='BxBxhxDxfxhxhxhxhxcxcx' +fi + +# List all files colorized in long format +alias l="ls -lF ${colorflag}" + +# List all files colorized in long format, including dot files +alias la="ls -laF ${colorflag}" + +# List only directories +alias lsd="ls -lF ${colorflag} | grep --color=never '^d'" + +# Always use color output for `ls` +alias ls="command ls ${colorflag}" + +# Always enable colored `grep` output +# Note: `GREP_OPTIONS="--color=auto"` is deprecated, hence the alias usage. +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' + + +# Stopwatch +alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date' + +# Get macOS Software Updates, and update installed Ruby gems, Homebrew, npm, and their installed packages +alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; sudo gem update --system; sudo gem update; sudo gem cleanup' + +# IP addresses +alias ip="dig +short myip.opendns.com @resolver1.opendns.com" +alias localip="ipconfig getifaddr en0" +alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" + +# Flush Directory Service cache +alias flush="dscacheutil -flushcache && killall -HUP mDNSResponder" + +# View HTTP traffic +alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'" +alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\"" + +# Recursively delete `.DS_Store` files +alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" + +# Empty the Trash on all mounted volumes and the main HDD. +# Also, clear Apple’s System Logs to improve shell startup speed. +# Finally, clear download history from quarantine. https://mths.be/bum +alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl; sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'" + +# Lock the screen (when going AFK) +alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend" diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f0dedc4 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true diff --git a/.functions b/.functions new file mode 100644 index 0000000..a000672 --- /dev/null +++ b/.functions @@ -0,0 +1,111 @@ +#!/usr/bin/env bash + +# Create a new directory and enter it +function mkd() { + mkdir -p "$@" && cd "$_"; +} + +# Create a .tar.gz archive, using `zopfli`, `pigz` or `gzip` for compression +function targz() { + local tmpFile="${@%/}.tar"; + tar -cvf "${tmpFile}" --exclude=".DS_Store" "${@}" || return 1; + + size=$( + stat -f"%z" "${tmpFile}" 2> /dev/null; # macOS `stat` + stat -c"%s" "${tmpFile}" 2> /dev/null; # GNU `stat` + ); + + local cmd=""; + if (( size < 52428800 )) && hash zopfli 2> /dev/null; then + # the .tar file is smaller than 50 MB and Zopfli is available; use it + cmd="zopfli"; + else + if hash pigz 2> /dev/null; then + cmd="pigz"; + else + cmd="gzip"; + fi; + fi; + + echo "Compressing .tar ($((size / 1000)) kB) using \`${cmd}\`…"; + "${cmd}" -v "${tmpFile}" || return 1; + [ -f "${tmpFile}" ] && rm "${tmpFile}"; + + zippedSize=$( + stat -f"%z" "${tmpFile}.gz" 2> /dev/null; # macOS `stat` + stat -c"%s" "${tmpFile}.gz" 2> /dev/null; # GNU `stat` + ); + + echo "${tmpFile}.gz ($((zippedSize / 1000)) kB) created successfully."; +} + +# Determine size of a file or total size of a directory +function fs() { + if du -b /dev/null > /dev/null 2>&1; then + local arg=-sbh; + else + local arg=-sh; + fi + if [[ -n "$@" ]]; then + du $arg -- "$@"; + else + du $arg .[^.]* ./*; + fi; +} + +# Use Git’s colored diff when available +hash git &>/dev/null; +if [ $? -eq 0 ]; then + function diff() { + git diff --no-index --color-words "$@"; + } +fi; + + +# Start a PHP server from a directory, optionally specifying the port +# (Requires PHP 5.4.0+.) +function phpserver() { + local port="${1:-4000}"; + local ip=$(ipconfig getifaddr en1); + sleep 1 && open "http://${ip}:${port}/" & + php -S "${ip}:${port}"; +} + + +# `s` with no arguments opens the current directory in Sublime Text, otherwise +# opens the given location +function s() { + if [ $# -eq 0 ]; then + subl .; + else + subl "$@"; + fi; +} + +# `a` with no arguments opens the current directory in Atom Editor, otherwise +# opens the given location +function a() { + if [ $# -eq 0 ]; then + atom .; + else + atom "$@"; + fi; +} + +# `o` with no arguments opens the current directory, otherwise opens the given +# location +function o() { + if [ $# -eq 0 ]; then + open .; + else + open "$@"; + fi; +} + +# `tre` is a shorthand for `tree` with hidden files and color enabled, ignoring +# the `.git` directory, listing directories first. The output gets piped into +# `less` with options to preserve color and line numbers, unless the output is +# small enough for one screen. +function tre() { + tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX; +} diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 0000000..0fb10f1 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,182 @@ +[alias] + + # View abbreviated SHA, description, and history graph of the latest 20 commits + l = log --pretty=oneline -n 20 --graph --abbrev-commit + + # View the current working tree status using the short format + s = status -s + + # Show the diff between the latest commit and the current state + d = !"git diff-index --quiet HEAD -- || clear; git --no-pager diff --patch-with-stat" + + # `git di $number` shows the diff between the state `$number` revisions ago and the current state + di = !"d() { git diff --patch-with-stat HEAD~$1; }; git diff-index --quiet HEAD -- || clear; d" + + # Pull in remote changes for the current repository and all its submodules + p = !"git pull; git submodule foreach git pull origin master" + + # Clone a repository including all submodules + c = clone --recursive + + # Commit all changes + ca = !git add -A && git commit -av + + # Switch to a branch, creating it if necessary + go = "!f() { git checkout -b \"$1\" 2> /dev/null || git checkout \"$1\"; }; f" + + # Show verbose output about tags, branches or remotes + tags = tag -l + branches = branch -a + remotes = remote -v + + # Amend the currently staged files to the latest commit + amend = commit --amend --reuse-message=HEAD + + # Credit an author on the latest commit + credit = "!f() { git commit --amend --author \"$1 <$2>\" -C HEAD; }; f" + + # Interactive rebase with the given number of latest commits + reb = "!r() { git rebase -i HEAD~$1; }; r" + + # Remove the old tag with this name and tag the latest commit with it. + retag = "!r() { git tag -d $1 && git push origin :refs/tags/$1 && git tag $1; }; r" + + # Find branches containing commit + fb = "!f() { git branch -a --contains $1; }; f" + + # Find tags containing commit + ft = "!f() { git describe --always --contains $1; }; f" + + # Find commits by source code + fc = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short -S$1; }; f" + + # Find commits by commit message + fm = "!f() { git log --pretty=format:'%C(yellow)%h %Cblue%ad %Creset%s%Cgreen [%cn] %Cred%d' --decorate --date=short --grep=$1; }; f" + + # Remove branches that have already been merged with master + # a.k.a. ‘delete merged’ + dm = "!git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d" + + # List contributors with number of commits + contributors = shortlog --summary --numbered + + # Merge GitHub pull request on top of the current branch or, + # if a branch name is specified, on top of the specified branch + mpr = "!f() { \ + declare currentBranch=\"$(git symbolic-ref --short HEAD)\"; \ + declare branch=\"${2:-$currentBranch}\"; \ + if [ $(printf \"%s\" \"$1\" | grep '^[0-9]\\+$' > /dev/null; printf $?) -eq 0 ]; then \ + git fetch origin refs/pull/$1/head:pr/$1 && \ + git checkout -B $branch && \ + git rebase $branch pr/$1 && \ + git checkout -B $branch && \ + git merge pr/$1 && \ + git branch -D pr/$1 && \ + git commit --amend -m \"$(git log -1 --pretty=%B)\n\nCloses #$1.\"; \ + fi \ + }; f" + +[apply] + + # Detect whitespace errors when applying a patch + whitespace = fix + +[core] + + # Use custom `.gitignore` and `.gitattributes` + excludesfile = ~/.gitignore + attributesfile = ~/.gitattributes + + # Treat spaces before tabs and all kinds of trailing whitespace as an error + # [default] trailing-space: looks for spaces at the end of a line + # [default] space-before-tab: looks for spaces before tabs at the beginning of a line + whitespace = space-before-tab,-indent-with-non-tab,trailing-space + + # Make `git rebase` safer on macOS + # More info: + trustctime = false + + # Prevent showing files whose names contain non-ASCII symbols as unversioned. + # http://michael-kuehnel.de/git/2014/11/21/git-mac-osx-and-german-umlaute.html + precomposeunicode = false + +[color] + + # Use colors in Git commands that are capable of colored output when + # outputting to the terminal. (This is the default setting in Git ≥ 1.8.4.) + ui = auto + +[color "branch"] + + current = yellow reverse + local = yellow + remote = green + +[color "diff"] + + meta = yellow bold + frag = magenta bold # line info + old = red # deletions + new = green # additions + +[color "status"] + + added = yellow + changed = green + untracked = cyan + +[commit] + + # https://help.github.com/articles/signing-commits-using-gpg/ + gpgsign = true + +[diff] + + # Detect copies as well as renames + renames = copies + +[diff "bin"] + + # Use `hexdump` to diff binary files + textconv = hexdump -v -C + +[help] + + # Automatically correct and execute mistyped commands + autocorrect = 1 + +[merge] + + # Include summaries of merged commits in newly created merge commit messages + log = true + +[push] + + # Use the Git 1.x.x default to avoid errors on machines with old Git + # installations. To use `simple` instead, add this to your `~/.extra` file: + # `git config --global push.default simple`. See http://git.io/mMah-w. + default = matching + # Make `git push` push relevant annotated tags when pushing branches out. + followTags = true + +# URL shorthands + +[url "git@github.com:"] + + insteadOf = "gh:" + pushInsteadOf = "github:" + pushInsteadOf = "git://github.com/" + +[url "git://github.com/"] + + insteadOf = "github:" + +[url "git@gist.github.com:"] + + insteadOf = "gst:" + pushInsteadOf = "gist:" + pushInsteadOf = "git://gist.github.com/" + +[url "git://gist.github.com/"] + + insteadOf = "gist:" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6fe9265 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +node_modules +bower_components + + +# Folder view configuration files +.DS_Store +Desktop.ini + +# Thumbnail cache files +._* +Thumbs.db + +# Files that might appear on external disks +.Spotlight-V100 +.Trashes diff --git a/README.md b/README.md index 4488bb9..dc75847 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Script to install base environment for Ruby development. ## Install on Mac OS X ``` -curl -L https://raw.githubusercontent.com/ombulabs/setup/master/mac.sh | bash +curl -L https://raw.githubusercontent.com/j0an/setup/master/mac.sh | bash ``` ## Installed libraries @@ -13,27 +13,32 @@ curl -L https://raw.githubusercontent.com/ombulabs/setup/master/mac.sh | bash The script will install: * homebrew -* imagemagick * oh-my-zsh * mysql -* postgres -* redis * rvm -* ruby-2.1.7 +* ruby-2.3.1 * nvm * qt * chromedriver -* github desktop -* heroku-toolbelt * spotify * slack * firefox +* atom (with some packages) +* flux +* dropbox +* skype +* sketch +* adobe photoshop cc +* vlc +* transmit +* transmission +* app cleaner # FAQ ## I get a permissions error. Why? -You may need to update your local libraries directory. +You may need to update your local libraries directory. ``` sudo chown -R $(whoami):admin /Library/Caches/Homebrew @@ -49,7 +54,7 @@ You have to install Xcode developer tools xcode-select --install ``` -## But I don't want \ installed. +## But I don't want \ installed. Just remove \ from https://github.com/ombulabs/setup/blob/master/mac.sh diff --git a/mac.sh b/mac.sh index a802abb..2cd7f4a 100755 --- a/mac.sh +++ b/mac.sh @@ -4,8 +4,13 @@ if [[ ! -d "$HOME/.bin/" ]]; then mkdir "$HOME/.bin" fi -if [ ! -f "$HOME/.bashrc" ]; then - touch $HOME/.bashrc +if [ ! -f "$HOME/.zshrc" ]; then + touch $HOME/.zshrc +fi + +// Create working directory +if [[ ! -d "$HOME/Sites/" ]]; then + mkdir "$HOME/Sites" fi println() { @@ -68,7 +73,7 @@ println "Installing Brew Cask..." println "Installing iTerm2..." brew cask install iterm2 - + println "Installing PhantomJS..." brew_install_or_upgrade 'phantomjs' @@ -78,18 +83,15 @@ println "Installing MySQL 5.6..." println "Installing QT, used by Capybara Webkit for integration testing..." brew_install_or_upgrade 'qt' - + println "Installing ChromeDriver, to drive Chrome via Selenium..." brew_install_or_upgrade 'chromedriver' println "Installing Git..." brew_install_or_upgrade 'git' -println "Installing Skype..." - brew cask install skype - -println "Installing Dropbox..." - brew cask install dropbox +println "Installing SourceTree..." + brew_install_or_upgrade 'sourcetree' println "Installing Firefox..." brew cask install firefox @@ -100,26 +102,83 @@ println "Installing Chrome..." println "Installing Atom..." brew cask install atom +println "Installing Atom Packages" + apm install file-type-icons + apm install atom-beautify + apm install auto-detect-indentation + apm install auto-update-packages + apm install pigments + apm install linter + apm install emmet + apm install merge-conflicts + apm install highlight-selected + apm install autoclose-html + apm install linter-csslint + apm install linter-htmlhint + apm install linter-jshint + apm install linter-rubocop + apm install linter-ruby + apm install linter-slim + apm install minimap + apm install rails-rspec + apm install ruby-block + apm install ruby-slim + apm install jshint + apm install autocomplete-paths + apm install autocomplete-plus + apm install autocomplete-ruby + apm install color-picker + apm install dockblockr + apm install editorconfig + apm install sublime-style-column-selection + apm install language-haml + apm install language-blade + println "Installing Slack..." brew cask install slack println "Installing Spotify..." brew cask install spotify - + +println "Installing Skype..." + brew cask install skype + +println "Installing Telegram..." + brew cask install telegram + +println "Installing Dropbox..." + brew cask install dropbox + +println "Installing Flux..." + brew cask install flux + +println "Installing Transmit..." + brew cask install transmit + +println "Installing AppCleaner..." + brew cask install appcleaner + +println "Installing Transmission..." + brew cask install transmission + println "Installing Sketch..." brew cask install sketch println "Installing Adobe Photoshop..." brew cask install adobe-photoshop-cc -node_version="4.6.0" +println "Installing VLC..." + brew cask install vlc + + +node_version="v4.6.0" println "Installing NVM, Node.js, and NPM, for running apps and installing JavaScript packages..." brew_install_or_upgrade 'nvm' - if ! grep -qs 'source $(brew --prefix nvm)/nvm.sh' ~/.bashrc; then - printf 'export PATH="$PATH:/usr/local/lib/node_modules"\n' >> ~/.bashrc - printf 'source $(brew --prefix nvm)/nvm.sh\n' >> ~/.bashrc + if ! grep -qs 'source $(brew --prefix nvm)/nvm.sh' ~/.zshrc; then + printf 'export PATH="$PATH:/usr/local/lib/node_modules"\n' >> ~/.zshrc + printf 'source $(brew --prefix nvm)/nvm.sh\n' >> ~/.zshrc fi source $(brew --prefix nvm)/nvm.sh @@ -147,7 +206,7 @@ ruby_version="2.3.1" println "Installing Ruby $ruby_version..." rvm install "$ruby_version" - rvm use "$ruby_version" + rvm use "$ruby_version" --default println "Updating to latest Rubygems version..." gem update --system @@ -155,3 +214,15 @@ println "Updating to latest Rubygems version..." println "Configuring Bundler for faster, parallel gem installation..." number_of_cores=$(sysctl -n hw.ncpu) bundle config --global jobs $((number_of_cores - 1)) + + +println "Cleanup..." + brew cleanup + brew cask cleanup + + +println "Loading OSX Config file..." + +if [ -f "$HOME/osx-config.sh" ]; then + . "$HOME/osx-config.sh" +fi diff --git a/osx-config.sh b/osx-config.sh new file mode 100644 index 0000000..cf5a365 --- /dev/null +++ b/osx-config.sh @@ -0,0 +1,533 @@ +#!/bin/sh + +# Alot of these configs have been taken from the various places +# on the web, most from here +# https://github.com/mathiasbynens/dotfiles/blob/master/.osx + +# Set the colo urs 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` + +# Color-echo. Improved. [Thanks @joaocunha] +# arg $1 = message +# arg $2 = Color +cecho() { + echo "${2}${1}${reset}" + return +} + + +# Here we go.. ask for the administrator password upfront and run a +# keep-alive to update existing `sudo` time stamp until script has finished +sudo -v +while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & + +############################################################################### +# General UI/UX +############################################################################### + + +# Disable the sound effects on boot +sudo nvram SystemAudioVolume=" " + +# Disable transparency in the menu bar and elsewhere on Yosemite +defaults write com.apple.universalaccess reduceTransparency -bool true + +echo "" +echo "Automatically quit printer app once the print jobs complete" +defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true + +# Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt` +echo "" +echo "Displaying ASCII control characters using caret notation in standard text views" +defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true + + +echo "" +echo "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 + +echo "" +echo "Check for software updates daily, not just once per week" +defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 + +############################################################################### +# General Power and Performance modifications +############################################################################### + +echo "" +echo "Disable hibernation? (speeds up entering sleep mode) (y/n)" +sudo pmset -a hibernatemode 0 + + +################################################################################ +# Trackpad, mouse, keyboard, Bluetooth accessories, and input +############################################################################### + + +echo "" +echo "Enabling full keyboard access for all controls (enable Tab in modal dialogs, menu windows, etc.)" +defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 + +echo "" +echo "Disabling press-and-hold for special keys in favor of key repeat" +defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false + +echo "" +echo "Setting a blazingly fast keyboard repeat rate" +defaults write NSGlobalDomain KeyRepeat -float 0.000000000001 + +echo "" +echo "Disable auto-correct" +defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false + + +echo "" +echo "Setting trackpad & mouse speed to a reasonable number" +defaults write -g com.apple.trackpad.scaling 2 +defaults write -g com.apple.mouse.scaling 2.5 + +echo "" +echo "Turn off keyboard illumination when computer is not used for 5 minutes" +defaults write com.apple.BezelServices kDimTime -int 300 + +echo "" +echo "Disable display from automatically adjusting brightness?" +sudo defaults write /Library/Preferences/com.apple.iokit.AmbientLightSensor "Automatic Display Enabled" -bool false + + +############################################################################### +# Screen +############################################################################### + +echo "" +echo "Requiring password immediately after sleep or screen saver begins" +defaults write com.apple.screensaver askForPassword -int 1 +defaults write com.apple.screensaver askForPasswordDelay -int 0 + +echo "" +screenshot_location="${HOME}/Screenshots" +echo "Setting location to ${screenshot_location}" +defaults write com.apple.screencapture location -string "${screenshot_location}" + + +echo "" +echo "Setting screenshot format to PNG" +defaults write com.apple.screencapture type -string "png" + +echo "" +echo "Enabling subpixel font rendering on non-Apple LCDs" +defaults write NSGlobalDomain AppleFontSmoothing -int 2 + +# Disable shadow in screenshots +defaults write com.apple.screencapture disable-shadow -bool true + +############################################################################### +# Finder +############################################################################### + +echo "" +echo "Show icons for hard drives, servers, and removable media on the desktop?" +defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true +defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true +defaults write com.apple.finder ShowMountedServersOnDesktop -bool true +defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true + +# Finder: disable window animations and Get Info animations +defaults write com.apple.finder DisableAllAnimations -bool true + + + +echo "" +echo "Show hidden files in Finder by default" +defaults write com.apple.finder AppleShowAllFiles -boolean true + +echo "" +echo "Show dotfiles in Finder by default" +defaults write com.apple.finder AppleShowAllFiles TRUE + +echo "" +echo "Show all filename extensions in Finder by default" +defaults write NSGlobalDomain AppleShowAllExtensions -bool true + +echo "" +echo "Show status bar in Finder by default" +defaults write com.apple.finder ShowStatusBar -bool true + +echo "" +echo "Display full POSIX path as Finder window title" +defaults write com.apple.finder _FXShowPosixPathInTitle -bool true + +echo "" +echo "Disable the warning when changing a file extension" +defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false + +echo "" +echo "Use list view in all Finder windows by default" +defaults write com.apple.finder FXPreferredViewStyle Nlsv + +echo "" +echo "Avoid creation of .DS_Store files on network volumes" +defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true + +echo "" +echo "Allowing text selection in Quick Look/Preview in Finder by default" +defaults write com.apple.finder QLEnableTextSelection -bool true + +# Keep folders on top when sorting by name +defaults write com.apple.finder _FXSortFoldersFirst -bool true + +# When performing a search, search the current folder by default +defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" + +# Enable spring loading for directories +defaults write NSGlobalDomain com.apple.springing.enabled -bool true + +# Remove the spring loading delay for directories +defaults write NSGlobalDomain com.apple.springing.delay -float 0 + +# 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 + +# Automatically open a new Finder window when a volume is mounted +defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true +defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true +defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true + + +# Disable the warning before emptying the Trash +defaults write com.apple.finder WarnOnEmptyTrash -bool false + + +# Show the ~/Library folder +chflags nohidden ~/Library + +echo "" +echo "Set highlight color to green" +defaults write NSGlobalDomain AppleHighlightColor -string "0.764700 0.976500 0.568600" + +echo "" +echo "Set sidebar icon size to small" +defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 1 + +echo "" +echo "Always show scrollbars" +defaults write NSGlobalDomain AppleShowScrollBars -string "Always" +# Possible values: `WhenScrolling`, `Automatic` and `Always` + +echo "" +echo "Disable the over-the-top focus ring animation" +defaults write NSGlobalDomain NSUseAnimatedFocusRing -bool false + +echo "" +echo "Increase window resize speed for Cocoa applications" +defaults write NSGlobalDomain NSWindowResizeTime -float 0.001 + +echo "" +echo "Expand save panel by default" +defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true +defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true + +echo "" +echo "Expand print panel by default" +defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true +defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true + +echo "" +echo "Save to disk (not to iCloud) by default" +defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false + +# 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 + +# Disable Notification Center and remove the menu bar icon +launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null + + +############################################################################### +# SSD-specific tweaks # +############################################################################### + +# Disable hibernation (speeds up entering sleep mode) +sudo pmset -a hibernatemode 0 + +# Remove the sleep image file to save disk space +sudo rm /private/var/vm/sleepimage +# Create a zero-byte file instead… +sudo touch /private/var/vm/sleepimage +# …and make sure it can’t be rewritten +sudo chflags uchg /private/var/vm/sleepimage + +# Disable the sudden motion sensor as it’s not useful for SSDs +sudo pmset -a sms 0 + + +############################################################################### +# Dock, Launchpad & Mission Control +############################################################################### + +echo "Wipe all (default) app icons from the Dock" +defaults write com.apple.dock persistent-apps -array + +# Enable highlight hover effect for the grid view of a stack (Dock) +defaults write com.apple.dock mouse-over-hilite-stack -bool true + +# Set the icon size of Dock items to 36 pixels +defaults write com.apple.dock tilesize -int 36 + +# Change minimize/maximize window effect +defaults write com.apple.dock mineffect -string "scale" + +# Minimize windows into their application’s icon +defaults write com.apple.dock minimize-to-application -bool true + +# Enable spring loading for all Dock items +defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true + +# Show indicator lights for open applications in the Dock +defaults write com.apple.dock show-process-indicators -bool true + +echo "Disable animation in Launchpad" +defaults write com.apple.dock springboard-hide-duration -int 0 +defaults write com.apple.dock springboard-show-duration -int 0 + +echo "" +echo "Setting the icon size of Dock items to 36 pixels for optimal size/screen-realestate" +defaults write com.apple.dock tilesize -int 36 + +echo "" +echo "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" +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 + + +# Don’t animate opening applications from the Dock +defaults write com.apple.dock launchanim -bool false + + +# Disable Dashboard +defaults write com.apple.dashboard mcx-disabled -bool true + +# Don’t show Dashboard as a Space +defaults write com.apple.dock dashboard-in-overlay -bool true + + +# Hot corners +# Possible values: +# 0: no-op +# 2: Mission Control +# 3: Show application windows +# 4: Desktop +# 5: Start screen saver +# 6: Disable screen saver +# 7: Dashboard +# 10: Put display to sleep +# 11: Launchpad +# 12: Notification Center +# Top left screen corner +defaults write com.apple.dock wvous-tl-corner -int 2 +defaults write com.apple.dock wvous-tl-modifier -int 0 +# Top right screen corner +defaults write com.apple.dock wvous-tr-corner -int 3 +defaults write com.apple.dock wvous-tr-modifier -int 0 +# Bottom left screen corner +defaults write com.apple.dock wvous-bl-corner -int 11 +defaults write com.apple.dock wvous-bl-modifier -int 0 +# Bottom right screen corner +defaults write com.apple.dock wvous-br-corner -int 4 +defaults write com.apple.dock wvous-br-modifier -int 0 + + + +############################################################################### +# Chrome, Safari, & WebKit +############################################################################### + +echo "" +echo "Privacy: Do not send search queries to Apple" +defaults write com.apple.Safari UniversalSearchEnabled -bool false +defaults write com.apple.Safari SuppressSearchSuggestions -bool true + +echo "" +echo "Hiding Safari's bookmarks bar by default" +defaults write com.apple.Safari ShowFavoritesBar -bool false + +echo "" +echo "Hiding Safari's sidebar in Top Sites" +defaults write com.apple.Safari ShowSidebarInTopSites -bool false + +echo "" +echo "Disabling Safari's thumbnail cache for History and Top Sites" +defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2 + +echo "" +echo "Enabling Safari's debug menu" +defaults write com.apple.Safari IncludeInternalDebugMenu -bool true + +echo "" +echo "Making Safari's search banners default to Contains instead of Starts With" +defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false + +echo "" +echo "Removing useless icons from Safari's bookmarks bar" +defaults write com.apple.Safari ProxiesInBookmarksBar "()" + +echo "" +echo "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 + +echo "" +echo "Adding a context menu item for showing the Web Inspector in web views" +defaults write NSGlobalDomain WebKitDeveloperExtras -bool true + +echo "" +echo "Disabling the annoying backswipe in Chrome" +defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false +defaults write com.google.Chrome.canary AppleEnableSwipeNavigateWithScrolls -bool false + +echo "" +echo "Using the system-native print preview dialog in Chrome" +defaults write com.google.Chrome DisablePrintPreview -bool true +defaults write com.google.Chrome.canary DisablePrintPreview -bool true + + + + +############################################################################### +# Time Machine +############################################################################### + +echo "" +echo "Prevent Time Machine from prompting to use new hard drives as backup volume" +defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true + + +echo "" +echo "Disable local Time Machine backups" +hash tmutil &> /dev/null && sudo tmutil disablelocal + + + +############################################################################### +# Transmission.app # +############################################################################### + + +echo "" +echo "Transmission for torrenting" + +mkdir -p ~/Downloads/Torrent/Incomplete + +echo "" +echo "Setting up an incomplete downloads folder in Downloads" +defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true +defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Torrent/Incomplete" + +echo "" +echo "Setting auto-add folder to be Downloads" +defaults write org.m0k.transmission AutoImportDirectory -string "${HOME}/Downloads/Torrent" + +echo "" +echo "Don't prompt for confirmation before downloading" +defaults write org.m0k.transmission DownloadAsk -bool false + +echo "" +echo "Trash original torrent files after adding them" +defaults write org.m0k.transmission DeleteOriginalTorrent -bool true + +echo "" +echo "Hiding the donate message" +defaults write org.m0k.transmission WarningDonate -bool false + +echo "" +echo "Hiding the legal disclaimer" +defaults write org.m0k.transmission WarningLegal -bool false + +echo "" +echo "Auto-resizing the window to fit transfers" +defaults write org.m0k.transmission AutoSize -bool true + +echo "" +echo "Auto updating to betas" +defaults write org.m0k.transmission AutoUpdateBeta -bool true + +echo "" +echo "Setting up the best 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" + + + +############################################################################### +# Git +############################################################################### +echo "" +echo "git Config" +echo "" +echo "Setting Git credentials" +git config --global user.name "Juan Manuel Garcia Olivares" +git config --global user.email "jmgolivares@gmail.com" + +echo "Setting Git to use Sublime Text as default editor" +git config --global core.editor "subl -n -w" + +############################################################################### +# Activity Monitor # +############################################################################### + +# Show the main window when launching Activity Monitor +defaults write com.apple.ActivityMonitor OpenMainWindow -bool true + +# Visualize CPU usage in the Activity Monitor Dock icon +defaults write com.apple.ActivityMonitor IconType -int 5 + +# Show all processes in Activity Monitor +defaults write com.apple.ActivityMonitor ShowCategory -int 0 + +# Sort Activity Monitor results by CPU usage +defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" +defaults write com.apple.ActivityMonitor SortDirection -int 0 + +############################################################################### +# Kill affected applications +############################################################################### + +echo "" +cecho "Done!" $cyan +echo "" +echo "" +cecho "################################################################################" $white +echo "" +echo "" +cecho "Restart your system" $red +echo "" + + + +# toDo +# config correcto del dock (magnification) +# config de reloj (mostrar fecha) +# config hotcorners +# appearance graphite +# use dark menu bar