Command Line Hacks - Mac Tips, Tricks & Shortcuts in easy steps (2015)

Mac Tips, Tricks & Shortcuts in easy steps (2015)

10

Command Line Hacks

Using UNIX commands may seem slightly arcane but there are many modifications you can make to OS X using the Command Line. In this section we will look at some Finder- and app-specific hacks you can make to your Mac.

Using Terminal commands

There are lots of apps that let you tinker under the hood with OS X, switching off and on various features. You can modify many aspects of the Mac using a Utility called Terminal (found in your Utilities folder). It allows you to type UNIX commands to the Mac. Unfortunately, Terminal is not a very user-friendly app and you have to be sure of what you are doing if you enter such commands. A wrong command can render your Mac useless, so try these out with caution!

image

Some of the commands are very useful, e.g. converting Apple Mail-copied email addresses into a more useful form, and others control the behavior of the Finder or other graphical features.

For many of these hacks, if you wish to return your Mac to normal, replace true in the command with false, YES with NO, and 1 with 0.

Many of the commands in the book wrap across two or more lines but when entering them in Terminal keep them on one line.

image

For many of these, you will need to log out and back in to your account to enable the changes.

Resources

There are many websites offering UNIX hacks for you to play with.

image

Finder Hacks

Change Dock delay time

This changes the time before the Dock appears when you hover the mouse over it.

defaults write com.apple.Dock autohide-delay-float 0

image

Add a gradient behind a stack item

This enables you to put a small gradient behind an icon.

defaults write com.apple.dock mouse-over-hilte-stack -boolean YES

killall Dock

Add a message to the Login window

This Terminal command enables you to add a message of your choice to the Login window. Sudo commands can be dangerous so use with care!

sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText “Your Message”

Replace “Your Message” with the message of your choice - don’t make it too long. To revert back to the default, type the following code:

sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText “”

Increase Dock magnification size

This hack lets you increase the size of the magnification of the Dock icons. Do not go higher than 512.

defaults write com.apple.dock largesize -int 512

Increase Desktop icon size

If you want massive icons on your Desktop, this hack lets you increase the icons to 512 pixels x 512 pixels. This may slow down older machines.

defaults write com.apple.finder DesktopViewOptions-dict IconSize -integer 512

killall Finder

Changing the format of Screenshots

You can change the default screenshot format to JPEG, TIFF, PNG, BMP, or GIF. You need to log out and back in again, or restart for the changes to take effect.

defaults write com.apple.screencapture type jpg

Change the Login picture

If you get bored with the Login screen, you can change it with this bit of code. Change the file location in the second half of the string to the exact file location of your chosen picture.

defaults write /Library/Preferences/com.apple.loginwindow DesktopPicture “/System/Library/ CoreServices/Finder.app/Contents/Resources/vortex.png”

image

Many of these hacks are available using apps, e.g. TinkerTool and several others.

Clear the Open With menu

If you right-click on a file you can open it with many applications. Sometimes your OS can get a little confused and list many applications. This hack clears this list and lets you start again.

/System/Library/Frameworks/CoreServices. framework/Versions/A/Frameworks/

LaunchServices.framework/Versions/A/Support/lsregister

-kill -r -domain local -domain system -domain user

Window drag speed

This hack changes the time delay it takes to drag windows around in spaces; it’s currently set to 0.75.

defaults write com.apple.dock workspaces-edge-delay -float 0.5

Disable Dashboard

If you don’t want or like the dashboard running, you can disable it. Change YES to NO to enable it again.

defaults write com.apple.dashboard mcx-disabled-boolean YES

killall Dock

Enable Double Scroll Arrows

This hack enables the double arrow set for up and down, left or right, to be at both ends of the scroll bar. Use System Preferences to reset.

defaults write “Apple Global Domain” AppleScrollBarVariant DoubleBoth

Increase the Dock size

This command enables you to change the size of the Dock. Use the sliders in System Preferences to reduce this size. Don’t go larger than 256.

defaults write com.apple.dock tilesize -int 256

Disable the Crash Dialog box

This disables the Quit Dialog box when an application crashes. Type “prompt” to enable it again.

defaults write com.apple.CrashReporter DialogType none

Drag a Widget onto the Desktop

This is a great hack, since it enables widgets to be placed onto the Desktop. Drag a widget around and press F12 to drag it onto the Desktop. Repeat the process again to drag a widget back onto the dashboard. You may need to log off or restart for it to take effect.

defaults write com.apple.dashboard devmode YES

List all open files

lsof

Eject a CD…

CDs and DVDs can get stuck. This hack helps you eject the disk (disc). Note: it may not always be Disk 1.

diskutil eject disk1

Count number of lines in the text in the Clipboard

pbpaste | wc -l

Count number of words in the text in the Clipboard

pbpaste | wc -w

Sort lines of text in the Clipboard and copy back to the Clipboard

pbpaste | sort | pbcopy

Reverse each line of text in the Clipboard

Makes each line appear backwards, and copies them back to the Clipboard.

pbpaste | rev | pbcopy

Strip duplicate lines from text in the Clipboard

pbpaste | sort | uniq | pbcopy

pbpaste | sort | uniq -d | pbcopy

pbpaste | sort | uniq -u | pbcopy

Tidy up HTML in the Clipboard and copy it back to the Clipboard

pbpaste | tidy | pbcopy

Display the first five lines from the Clipboard

pbpaste | head -n 5

Display the last five lines from the Clipboard

pbpaste | tail -n 5

Convert tabs to spaces for the lines in the Clipboard

pbpaste | expand | pbcopy

Display a history of commands used in the terminal by the current user

history

Convert a file to HTML

textutil -convert html file.extension

Nano (text editor)

For quick changes to text files.

nano [file_to_edit]

Use Control + O to Save and Control + X to quit.

clear

Key repeat rate

You can re-enable the repeat key presses (off by default) with this Terminal command.

defaults write -g ApplePressAndHoldEnabled -bool false

To reverse, replace the “false” at the end with a “true”.

Disable Yosemite’s window animations

defaults write NSGlobalDomain
NSAutomaticWindowAnimationsEnabled -bool false

To reverse, replace “false” in the above command with “true”.

Enable AirDrop on unsupported Macs and over Ethernet

AirDrop will only work with newer Macs and over Wi-Fi. If you wish to enable this feature on some older systems and over Ethernet, use this hack.

defaults write com.apple.NetworkBrowser
BrowseAllInterfaces -bool true

To return your Mac to normal, replace “true” in the above command with “false”.

Disable Smooth Scrolling

Use this hack to switch off smooth scrolling and return OS X to its pre-Smooth Scrolling functionality.

defaults write -g NSScrollAnimationEnabled -bool NO

To enable Smooth Scrolling again, replace the “NO” in the above statement with “YES”.

Disable Rubber Band Effect

defaults write -g NSScrollViewRubberbanding -int 0

This does not work for every app. You will need to restart apps on an app-by-app basis to see the change. Replace “0” in the above command with a “1” to re-enable the rubber band effect.

Check which Processes are using the Internet

lsof -P -i -n | cut -f 1 -d “ “ | uniq

Menu bar: disable Transparency

defaults write NSGlobalDomain
AppleEnableMenuBarTransparency -bool false

Menu bar: show remaining Battery Time; hide percentage

defaults write com.apple.menuextra.battery
ShowPercent -string “NO”

defaults write com.apple.menuextra.battery
ShowTime -string “YES”

Menu bar: hide the Time Machine and Volume icons

defaults write com.apple.systemuiserver menuExtras -array “/System/Library/CoreServices/ Menu Extras/Bluetooth.menu” “/System/Library/ CoreServices/Menu Extras/AirPort.menu” “/System/ Library/CoreServices/Menu Extras/Battery.menu” “/ System/Library/CoreServices/Menu Extras/Clock. menu”

Always show Scroll bars

defaults write NSGlobalDomain AppleShowScrollBars-string “Always”

Disable opening and closing window animations

defaults write NSGlobalDomain
NSAutomaticWindowAnimationsEnabled -bool false

Increase window resize speed for Cocoa applications

defaults write NSGlobalDomain NSWindowResizeTime-float 0.001

Expand Save panel by default

defaults write NSGlobalDomain
NSNavPanelExpandedStateForSaveMode -bool true

Expand Print panel by default

defaults write NSGlobalDomain
PMPrintingExpandedStateForPrint -bool true

Disable the “Are you sure you want to open this application?” dialog

defaults write com.apple.LaunchServices
LSQuarantine -bool false

Display ASCII control characters using caret notation in standard text views

defaults write NSGlobalDomain
NSTextShowsControlCharacters -bool true

Disable Resume system-wide

defaults write NSGlobalDomain
NSQuitAlwaysKeepsWindows -bool false

Disable Automatic Termination of Inactive Apps

defaults write NSGlobalDomain
NSDisableAutomaticTermination -bool true

Trackpad: enable tap to Click for this user and for the Login screen

defaults write com.apple.driver.
AppleBluetoothMultitouch.trackpad Clicking -bool true

defaults -currentHost write NSGlobalDomain com. apple.mouse.tapBehavior -int 1

defaults write NSGlobalDomain com.apple.mouse. tapBehavior -int 1

Trackpad: map bottom right corner to right-click

defaults write com.apple.driver.
AppleBluetoothMultitouch.trackpad
TrackpadCornerSecondaryClick -int 2

defaults write com.apple.driver.
AppleBluetoothMultitouch.trackpad
TrackpadRightClick -bool true

defaults -currentHost write NSGlobalDomain com.
apple.trackpad.trackpadCornerClickBehavior -int 1

defaults -currentHost write NSGlobalDomain com.
apple.trackpad.enableSecondaryClick -bool true

Trackpad: swipe between pages with three fingers

defaults write NSGlobalDomain
AppleEnableSwipeNavigateWithScrolls -bool true

defaults -currentHost write NSGlobalDomain com.
apple.trackpad.threeFingerHorizSwipeGesture -int 1

defaults write com.apple.driver.
AppleBluetoothMultitouch.trackpad
TrackpadThreeFingerHorizSwipeGesture -int 1

Disable “natural” scrolling

Some people like this but it’s the first thing I switch off. It feels anything but natural!

defaults write NSGlobalDomain com.apple.
swipescrolldirection -bool false

Increase sound quality for Bluetooth headphones/headsets

defaults write com.apple.BluetoothAudioAgent
“Apple Bitpool Min (editable)” -int 40

Enable full keyboard access for all controls

defaults write NSGlobalDomain AppleKeyboardUIMode -int 3

Disable press-and-hold for keys in favor of key repeat

defaults write NSGlobalDomain
ApplePressAndHoldEnabled -bool false

Set a fast keyboard repeat rate

defaults write NSGlobalDomain KeyRepeat -int 0

Set language and text formats

If you are in the US, replace “EUR” with “USD”, “Centimeters” with “Inches”, and “true” with “false”.

defaults write NSGlobalDomain AppleLanguages -array “en” “nl”

defaults write NSGlobalDomain AppleLocale -string “en_GB@currency=EUR”

defaults write NSGlobalDomain
AppleMeasurementUnits -string “Centimeters”

defaults write NSGlobalDomain AppleMetricUnits -bool true

Disable Auto-correct

defaults write NSGlobalDomain
NSAutomaticSpellingCorrectionEnabled -bool false

Kill a Process

Sometimes you just need a process to stop running. If you want to kill it in Terminal without using Activity Monitor, find the process ID (in Activity Monitor) and then use the following command.

kill PID 478

Let Terminal Talk

You can get Terminal to speak anything back to you using the voice engine. Replace “hello” with anything you want.

say hello

Make Hidden Applications' icons transparent

If you hide a lot of applications, you can make their icons transparent in the dock.

defaults write com.apple.Dock showhidden -bool
YES

killall Dock

Make the Dock spring-loaded

Makes the dock spring-loaded so you can open files or windows from within the dock.

defaults write com.apple.dock enable-spring-load-actions- on-all-items -boolean YES

Recent Applications Stack

This command creates a new stack in your dock so you can view the recently-used Applications.

defaults write com.apple.dock persistent-others -array-add ‘{ “tile-data” = { “list-type” = 1; }; “tile-type” = “recents-tile”; }’

Pin Dock to the right

defaults write com.apple.dock pinning -string
“start”

Pin Dock to the left

defaults write com.apple.dock pinning -string
“end”

Pin Dock to the center (back to the way it was)

defaults write com.apple.dock pinning -string
“middle”

Quick Look a file

This command lets you Quick Look a file in Terminal. First, you need to change the folder by using the “cd” command and then enter the folder you want. To enable this command to work you need to type the file name exactly.

qlmanage -p “Jaguar Aqua Graphite.jpg”

Disable the Spotlight icon

This command removes the Spotlight icon. Type 755 to re-enable it, instead of 0.

sudo chmod 0 /System/Library/CoreServices/ Spotlight.app

killall Spotlight

Remove the stripes in List View

A simple hack that removes the alternating stripes in List View in Finder.

defaults write com.apple.finder FXListViewStripes -bool FALSE

killall Finder

Change the Menu Bar to white

If you don’t like the transparent menu bar you can change it so that it appears white. This requires a password and you will need to restart your Mac.

sudo defaults write /System/Library/
LaunchDaemons/com.apple.WindowServer
‘EnvironmentVariables’ -dict ‘CI_NO_BACKGROUND_ IMAGE’ 1

Change the Menu Bar to gray

If you don’t like the white version of the menu bar you can change it so that it appears gray.

sudo defaults write /System/Library/
LaunchDaemons/com.apple.WindowServer
‘EnvironmentVariables’ -dict ‘CI_NO_BACKGROUND_ IMAGE’ 0

Revert the Menu Bar back to default

If you prefer the transparent menu bar and you want it back, type the following into Terminal.

sudo defaults delete /System/Library/
LaunchDaemons/com.apple.WindowServer
‘EnvironmentVariables’

Set the expanded Print dialog as default

If you want access to a lot of the extra print menus by default you can use the following command to enable you to do this. Requires a restart.

defaults write -g PMPrintingExpandedStateForPrint -bool TRUE

Set the expanded Save dialog as default

Similar to the print dialog, this sets the save dialog to the expanded view by default. This requires a restart.

defaults write -g
NSNavPanelExpandedStateForSaveMode -bool TRUE

Set the Screen saver as the wallpaper

This command sets the currently-selected screen saver as the Desktop background.

/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background

Show Hidden Files in Finder

A lot of the files in Finder are hidden. If you want to take a look at how many there are and what they are, you can show them within Finder. Be careful, as these files are needed by the system.

Repeat the command with “false” to revert.

defaults write com.apple.finder AppleShowAllFiles
TRUE

Skip Disk Image verification

If you want to save some time you can skip the disk image verification for a disk image.

com.apple.frameworks.diskimages skip-verify TRUE

Show Sub-folders in graphical format in Terminal

This is a very cool hack that enables you to show an ASCII graphical view of sub-folders. Use the cd command to change to a directory, otherwise the command will list every folder.

ls -R | grep “:$” | sed -e ‘s/:$//’ -e ‘s/[^-] [^\/]*\//--/g’ -e ‘s/^/ /’ -e ‘s/-/|/’

Speed up Dialog boxes

Most dialog boxes have an animation effect that looks cool. If you want to speed this up you can change the speed at which it renders so it appears almost instantly. The default is 0.2.

defaults write NSGlobalDomain NSWindowResizeTime
0.01

Restart Mac OS X

shutdown - r now

Shutdown Mac OS X

shutdown now

Get overview of current Power Management Settings

pmset -g

Put Display to sleep after 15 minutes of inactivity

sudo pmset displaysleep 15

Put Computer to sleep after 30 minutes of inactivity

sudo pmset sleep 30

Permanently disable Dock icon bouncing

$ defaults write com.apple.dock no-bouncing -bool TRUE

$ killall Dock

Disable Dashboard (don’t forget to drag the Dashboard Dock icon off the Dock too)

defaults write com.apple.dashboard mcx-disabled -boolean YES

killall Dock

Enable Dashboard

defaults write com.apple.dashboard mcx-disabled -boolean NO

killall Dock

Force the Finder to show hidden files

This is useful for Web Developers who need to edit .htaccess files, for example.

defaults write com.apple.finder AppleShowAllFiles TRUE

Force the Finder to hide hidden files

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

Save Screenshots to the Desktop

defaults write com.apple.screencapture location -string “$HOME/Desktop”

Disable shadow in Screenshots

defaults write com.apple.screencapture disable-shadow -bool true

Enable subpixel font rendering on non-Apple LCDs

defaults write NSGlobalDomain AppleFontSmoothing -int 2

Finder: allow quitting via ⌘ + Q; doing so will also hide Desktop icons

defaults write com.apple.finder QuitMenuItem -bool true

Finder: disable window animations and Get Info animations

defaults write com.apple.finder
DisableAllAnimations -bool true

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: show hidden files by default

defaults write com.apple.Finder AppleShowAllFiles -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: allow text selection in Quick Look

defaults write com.apple.finder
QLEnableTextSelection -bool true

Display full POSIX path as Finder window title

defaults write com.apple.finder
FXShowPosixPathInTitle -bool true

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

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

Show item info below icons on the Desktop and in other icon views

/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

Enable snap-to-grid for icons on the Desktop and in other icon views

/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

Increase grid spacing for icons on the Desktop and in other icon views

/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

Increase the size of icons on the Desktop and in other icon views

/usr/libexec/PlistBuddy -c “Set :DesktopViewSettings:IconViewSettings:iconSize 80” ~/Library/ Preferences/com.apple.finder.plist

/usr/libexec/PlistBuddy -c “Set :FK_StandardViewSettings:IconViewSettings:iconSize 80” ~/Library/ Preferences/com.apple.finder.plist

/usr/libexec/PlistBuddy -c “Set :StandardViewSettings:IconViewSettings:iconSize 80” ~/Library/ Preferences/com.apple.finder.plist

Disable the warning before emptying the Trash

defaults write com.apple.finder WarnOnEmptyTrash -bool false

Empty Trash securely by default

defaults write com.apple.finder EmptyTrashSecurely -bool true

Show the ~/Library folder

chflags nohidden ~/Library

Remove Dropbox’s green checkmark icons in Finder

file=/Applications/Dropbox.app/Contents/Resources/ check.icns

[ -e “$file” ] && mv -f “$file” “$file.bak”

unset file

Enable highlight hover effect for the grid view of a stack (Dock)

defaults write com.apple.dock mouse-over-hilte-stack -bool true

Set the icon size of Dock items to 36 pixels

defaults write com.apple.dock tilesize -int 36

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

Don’t animate opening applications from the Dock

defaults write com.apple.dock launchanim -bool false

Speed up Mission Control animations

defaults write com.apple.dock expose-animation-
duration -float 0.1

Top left screen corner → Mission Control

defaults write com.apple.dock wvous-tl-corner
-int 2

defaults write com.apple.dock wvous-tl-modifier
-int 0

Top right screen corner → Desktop

defaults write com.apple.dock wvous-tr-corner
-int 4

defaults write com.apple.dock wvous-tr-modifier
-int 0

Bottom left screen corner → Start Screen saver

defaults write com.apple.dock wvous-bl-corner
-int 5

defaults write com.apple.dock wvous-bl-modifier
-int 0

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

#defaults write com.apple.dock no-glass -bool true

Automatically hide and show the Dock

defaults write com.apple.dock autohide -bool true

Make Dock icons of hidden applications translucent

defaults write com.apple.dock showhidden -bool true

Reset Launchpad

find ~/Library/Application\ Support/Dock -name “*.db” -maxdepth 1 -delete

Add a spacer to the left side of the Dock (where the applications are)

#defaults write com.apple.dock persistent-apps -array-add ‘{tile-data={}; tile-type=”spacer-tile”;}’

Add a spacer to the right side of the Dock (where the Trash is)

#defaults write com.apple.dock persistent-others -array-add ‘{tile-data={}; tile-type=”spacer-tile”;}’

Add a context menu item for showing the Web Inspector in web views

defaults write NSGlobalDomain
WebKitDeveloperExtras -bool true

Enable Dashboard dev mode (allows keeping widgets on the Desktop)

defaults write com.apple.dashboard devmode -bool true

Disable smart quotes as it’s annoying for code Tweets

defaults write com.twitter.twitter-mac
AutomaticQuoteSubstitutionEnabled -bool false

Show the app window when clicking the menu icon

defaults write com.twitter.twitter-mac
MenuItemBehavior -int 1

Enable the hidden “Develop” menu

defaults write com.twitter.twitter-mac
ShowDevelopMenu -bool true

Hide the app in the background if it’s not the frontmost window

This is a very useful command for anyone who does a lot of fiddling and needs to quit Finder.

defaults write com.apple.finder QuitMenuItem -bool YES

killall Finder

App-specific Commands

Web inspector for Safari

This is a very detailed web inspector that enables you to find out specific information about a page. It is accessible through the debug menu but this enables you to use it without. You can access it quickly through right-click.

defaults write com.apple.Safari
WebKitDeveloperExtras -bool true

See current path of Finder window

defaults write com.apple.finder _
FXShowPosixPathInTitle -bool YES

Enable Time Machine on unsupported drives

This hack enables Time Machine to work on unsupported drives such as a NAS. Use with caution as it is unsupported.

defaults write com.apple.systempreferences
TMShowUnsupportedNetworkVolumes 1

Increase Time Machine backups

To change to half-hourly backups use this hack.

sudo defaults write /System/Library/
LaunchDaemons/com.apple.backupd-auto
StartInterval -int 1800

Enable the debug menu in iCal

defaults write com.apple.iCal IncludeDebugMenu -bool true

hash tmutil &> /dev/null && sudo tmutil disablelocal

Force Mail to display in plain text

defaults write com.apple.mail PreferPlainText -bool TRUE

Disable Tooltips in Safari

This quick hack for Safari removes the tooltips you get when you hover over certain elements.

defaults write com.apple.Safari
WebKitShowsURLsInToolTips 0

Change the loading bar in Safari to a pie chart

This changes the blue bar that goes across the address bar into a small blue pie chart. Insert “false” instead of “true” to reverse.

defaults write com.apple.Safari
DebugUsePieProgressIndicator -bool true

Enable debug menu in Safari

Adding debug menus to programs is great, as you can access a whole range of features. This one is for Safari.

defaults write com.apple.Safari IncludeDebugMenu 1

Set the history limit in Safari to a number of items

defaults write com.apple.Safari
WebKitHistoryItemLimit 2000

Set the history limit in Safari to a number of days

defaults write com.apple.Safari
WebKitHistoryAgeInDaysLimit 30

Disable Safari’s thumbnail cache for history and top sites

defaults write com.apple.Safari
DebugSnapshotsUpdatePolicy -int 2

defaults write com.apple.Safari
IncludeInternalDebugMenu -bool true

Make Safari’s search banners default to “contains” instead of “starts with”

defaults write com.apple.Safari
FindOnPageMatchesWordStartsOnly -bool false

Remove unwanted icons from Safari’s bookmarks bar

defaults write com.apple.Safari
ProxiesInBookmarksBar “()”

Change the arrows in iTunes

Normally the arrows in iTunes link to the music store. Adding this command enables you to search your library. You need to click on the song first for the arrows to appear.

defaults write com.apple.iTunes invertStoreLinks -bool YES

Change iTunes link behavior to point at local iTunes Library instead of iTunes Store

defaults write com.apple.iTunes invertStoreLinks -bool true

defaults write com.apple.iTunes invertStoreLinks -bool YES

Disable the iTunes arrow links completely

defaults write com.apple.iTunes show-store-arrow-links -bool false

Enable iTunes track notifications in the Dock

defaults write com.apple.dock itunes-notifications -bool true

Make ⌘ + F focus the search input in iTunes

defaults write com.apple.iTunes
NSUserKeyEquivalents -dict-add “Target Search Field” “@F”

Sync to Dropbox from anywhere in your home folder

Using this Terminal command you can create symbolic links to folders you want to sync within Dropbox.

(replace username, foldername, and path/to/
dropbox with your own values):

ln -s /Users/username/Documents/foldername / Users/path/to/dropbox/Files/

Disable send and reply animations in Mail.app

defaults write com.apple.Mail
DisableReplyAnimations -bool true

defaults write com.apple.Mail
DisableSendAnimations -bool true

Copy email addresses as “johndoe@mac.com” instead of John Doe <johndoe@mac.com> in Mail.app

defaults write com.apple.mail
AddressesIncludeNameOnPasteboard -bool false

Enable the debug menu in Disk Utility

defaults write com.apple.DiskUtility
DUDebugMenuEnabled -bool true

Prevent Time Machine from prompting to use new hard drives as backup volume

defaults write com.apple.TimeMachine
DoNotOfferNewDisksForBackup -bool true

Enable the debug menu in Address Book

defaults write com.apple.addressbook
ABShowDebugMenu -bool true

Entertainment

Play Star Wars Episode IV

Using a simple Telnet address your Terminal will connect in and play Star Wars Episode IV in ASCII format!

telnet towel.blinkenlights.nl

image

Tetris and Pong

Open Terminal, type

emacs

Click Enter

Press ESC + X at the same time

Type

tetris

image

or

pong

image

Use the arrow keys to move and rotate the blocks, and press the space to make the blocks fall.

Networking and Internet

Ping a host to see whether it’s available

ping -o leftcolumn.net

Troubleshoot routing problems to a host using traceroute

traceroute leftcolumn.net

Check whether a host is running an HTTP server (i.e. check that a website is available)

curl -I www.leftcolumn.net | head -n 1

Who is logged in to your Mac?

who

image

Show routing table

netstat -r

Show active network connections

netstat -an

Show network statistics

netstat -s

Restart Bonjour

Useful when a Mac "disappears" from the Network.

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

sudo launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist