Skip to content

Instantly share code, notes, and snippets.

@sydneyitguy
Forked from DAddYE/hack.sh
Last active December 17, 2015 07:29
Show Gist options
  • Save sydneyitguy/5572931 to your computer and use it in GitHub Desktop.
Save sydneyitguy/5572931 to your computer and use it in GitHub Desktop.
#!/bin/sh
##
# This is a script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# Run in interactive mode with:
# $ sh -c "$(curl -sL https://gist.github.com/sydneyitguy/5572931/raw/osx_hack.sh)"
#
# or run it without prompt questions:
# $ sh -c "$(curl -sL https://gist.github.com/sydneyitguy/5572931/raw/osx_hack.sh)" -s silent
#
# Please, share your tips commenting here:
# https://gist.github.com/2108403
#
# Author: @DAddYE
# Thanks to: @mathiasbynens
#
case $1 in
"-s" | "-y" | "--silent" | "silent" )
echo "Running in silent mode..."
auto=Y
shift 1
;;
*)
auto=N
if [ ! -t 0 ]; then
echo "Interactive mode needs terminal!" >&2
exit 1
fi
;;
esac
function ask {
while true; do
if [ "$2" == "Y" ]; then
prompt="\033[1;32mY\033[0m/n"
default=Y
elif [ "$2" == "N" ]; then
prompt="y/\033[1;32mN\033[0m"
default=N
else
prompt="y/n"
default=
fi
printf "$1 [$prompt] "
if [ "$auto" == "Y" ]; then
echo
else
read yn
fi
if [ -z "$yz" ]; then
yn=$default
fi
case $yn in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
esac
done
}
if ask "Show all filename extensions in Finder" Y; then
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
fi
if ask "Disable press-and-hold for keys in favor of key repeat" Y; then
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
fi
if ask "Set a blazingly fast keyboard repeat rate" Y; then
defaults write NSGlobalDomain KeyRepeat -int 0
fi
if ask "Set a shorter Delay until key repeat" Y; then
defaults write NSGlobalDomain InitialKeyRepeat -int 18
fi
if ask "Use current directory as default search scope in Finder" Y; then
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
fi
if ask "Show Path bar in Finder" Y; then
defaults write com.apple.finder ShowPathbar -bool true
fi
if ask "Show Status bar in Finder" Y; then
defaults write com.apple.finder ShowStatusBar -bool true
fi
if ask "Automatically open a new Finder window when a volume is mounted" Y; then
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
fi
if ask "Display full POSIX path as Finder window title" Y; then
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
fi
if ask "Disable the warning when changing a file extension" Y; then
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
fi
if ask "Set the icon size of the Dock to 40 pixels" Y; then
defaults write com.apple.dock tilesize -int 40
fi
if ask "Move Dock on the Right" Y; then
defaults write com.apple.dock orientation -string "right"
fi
if ask "Enable AirDrop over Ethernet and on unsupported Macs running Lion" Y; then
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
fi
if ask "Avoid creating .DS_Store files on network volumes" Y; then
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
fi
if ask "Enable tap to click on Trackpad and login screen" Y; then
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write com.apple.mouse.tapBehaviour -int 1
fi
if ask "Disable Natural Scroll Direction" Y; then
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false
fi
if ask "A bit faster Trackpad" Y; then
defaults write NSGlobalDomain com.apple.trackpad.scaling -float 2
fi
if ask "Only use UTF-8 in Terminal.app" Y; then
defaults write com.apple.terminal StringEncodings -array 4
fi
if ask "Show the ~/Library folder" Y; then
chflags nohidden ~/Library
fi
if ask "Disable local Time Machine backups" Y; then
hash tmutil &> /dev/null && sudo tmutil disablelocal
fi
if ask "Kill affected applications" Y; then
for app in Safari Finder Dock Mail SystemUIServer; do
killall "$app" >/dev/null 2>&1
done
echo
echo "** \033[33mSome changes needs a reboot to take effect\033[0m **"
echo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment