Terminal Tricks


A crib sheet for useful OS X terminal commands…

Command Line

# Talk
say [-f <file>]
# Two finger browser navigation
defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE
defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool TRUE
# Uptime
caffeinate -u -t 6000
# Airdrop
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool TRUE
killall Finder
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool FALSE
killall Finder
# How long
# All proceses
# Image to volume
sudo asr -restore -noverify -source /path/to/diskimage/dmg -target /Volumes/VolumeToRestoreTo
# Reboot on freeze
sudo systemsetup -setrestartfreeze on
# Dock
defaults write com.apple.Dock showhidden -bool TRUE
killall Dock
defaults write com.apple.dock static-only -bool TRUE
killall Dock 
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
# Dashboard
defaults write com.apple.dashboard mcx-disabled -boolean TRUE
killall Dock
# Welcome
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "In case of loss, call 555-555-5555."
sudo defaults delete /Library/Preferences/com.apple.loginwindow LoginwindowText
# Show all
defaults write com.apple.finder AppleShowAllFiles -bool TRUE
killall Finder
defaults write com.apple.finder AppleShowAllFiles -bool FALSE
killall Finder
ditto <from> <to>
# Download
curl -O [the URL of the file]
# View
# Disk Usage
sudo fs_usage
# Quick look - text select
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
killall Finder
defaults write com.apple.finder QLEnableTextSelection -bool FALSE
killall Finder
# History
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'select LSQuarantineDataURLString from LSQuarantineEvent'
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'
# Screenshots - type
defaults write com.apple.screencapture type jpg
# Screenshots - location
defaults write com.apple.screencapture location ~/your/location/here
killall SystemUIServer
# Screenshots - shadow
defaults write com.apple.screencapture disable-shadow -bool TRUE
killall SystemUIServer
# Screenshots - name
defaults write com.apple.screencapture name "New Screen Shot Name"
killall SystemUIServer
# Screenshots - reset name
defaults write com.apple.screencapture name ""
killall SystemUIServer
# Updates - check
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
# Updates - install all
sudo softwareupdate -ia
# Updates - list
sudo softwareupdate -l
# Shutdown
sudo shutdown [-r|-h] [now|+<secs>]
# Previous command
# Web server in CWD
python -m SimpleHTTPServer 8000
# Open file in specific application
open -a /Applications/AppName.app /path/to/file.txt
# Stress test
# Recreate Spotlight
sudo mdutil -E /Volumes/DriveName
# Recreate Open with...
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# Create sized file
mkfile 1g test.abc
# IP address - internal
ipconfig getifaddr en0
# IP - address - external
curl ipecho.net/plain; echo
# Mail reply animation
defaults delete com.apple.mail DisableReplyAnimations -bool TRUE
defaults delete com.apple.mail DisableReplyAnimations -bool FALSE
# iCloud - block
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool FALSE
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool TRUE
# Open current folder in Finder
open .



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s