# Reduce Transparency
defaults write com.apple.universalaccess reduceTransparency -bool true
# Restore Default Transparency
defaults write com.apple.universalaccess reduceTransparency -bool false
# Up to Mountain Lion
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "/path/to/picture.jpg"'
# Since Mavericks
sqlite3 ~/Library/Application\ Support/Dock/desktoppicture.db "update data set value = '/path/to/picture.jpg'" && killall Dock
find /Applications -path '*Contents/_MASReceipt/receipt' -maxdepth 4 -print |\sed 's#.app/Contents/_MASReceipt/receipt#.app#g; s#/Applications/##'
# Enable
defaults write com.apple.appstore ShowDebugMenu -bool true
# Disable (Default)
defaults write com.apple.appstore ShowDebugMenu -bool false
sudo rm -rf /var/db/RemoteManagement ; \
sudo defaults delete /Library/Preferences/com.apple.RemoteDesktop.plist ; \
defaults delete ~/Library/Preferences/com.apple.RemoteDesktop.plist ; \
sudo rm -r /Library/Application\ Support/Apple/Remote\ Desktop/ ; \
rm -r ~/Library/Application\ Support/Remote\ Desktop/ ; \
rm -r ~/Library/Containers/com.apple.RemoteDesktop
# Enable
defaults write com.apple.addressbook ABShowDebugMenu -bool true
# Disable (Default)
defaults write com.apple.addressbook ABShowDebugMenu -bool false
# Stop Responding to Key Presses
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist
# Respond to Key Presses (Default)
launchctl load -w /System/Library/LaunchAgents/com.apple.rcd.plist
defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes
The AppleScript code below will quit Mail, vacuum the SQLite index, then re-open Mail. On a large email database that hasn’t been optimized for a while, this can provide significant improvements in responsiveness and speed.
(*
Speed up Mail.app by vacuuming the Envelope Index
Code from: http://www.hawkwings.net/2007/03/03/scripts-to-automate-the-mailapp-envelope-speed-trick/
Originally by "pmbuko" with modifications by Romulo
Updated by Brett Terpstra 2012
Updated by Mathias Törnblom 2015 to support V3 in El Capitan and still keep backwards compatibility
*)
tell application "Mail" to quit
set os_version to do shell script "sw_vers -productVersion"
set mail_version to "V2"
considering numeric strings
if "10.10" <= os_version then set mail_version to "V3"
end considering
set sizeBefore to do shell script "ls -lnah ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
do shell script "/usr/bin/sqlite3 ~/Library/Mail/" & mail_version & "/MailData/Envelope\\ Index vacuum"
set sizeAfter to do shell script "ls -lnah ~/Library/Mail/" & mail_version & "/MailData | grep -E 'Envelope Index$' | awk {'print $5'}"
display dialog ("Mail index before: " & sizeBefore & return & "Mail index after: "
& sizeAfter & return & return & "Enjoy the new speed!")
tell application "Mail" to activate
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
Other options: get source
, get text
.
osascript -e 'tell application "Safari" to get URL of current tab of front window'
defaults write com.bohemiancoding.sketch3 exportCompactSVG -bool yes
Removes the dialog and defaults to auto reload.
defaults write -app Skim SKAutoReloadFileUpdate -boolean true
defaults write com.apple.TextEdit RichText -int 0
This changes the interval to 30 minutes. The integer value is the time in seconds.
sudo defaults write /System/Library/Launch Daemons/com.apple.backupd-auto StartInterval -int 1800
Whether Time Machine performs local backups while the Time Machine backup volume is not available.
# Disable
sudo tmutil disablelocal
# Enable (Default)
sudo tmutil enablelocal
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Disable Local Time Machine Backups
hash tmutil &> /dev/null && sudo tmutil disablelocal
# Enable Local Time Machine Backups (Default)
hash tmutil &> /dev/null && sudo tmutil enablelocal
Compiling MacVim via Homebrew with all bells and whistles, including overriding system Vim.
brew install macvim --HEAD --with-cscope --with-lua --with-override-system-vim --with-luajit --with-python
Install the development version of this modern Vim drop-in alternative via Homebrew.
brew tap neovim/neovim && \
brew install neovim
xcode-select --install
xcrun simctl delete unavailable
Leaving this turned on is useless when you’re using SSDs.
sudo pmset -a sms 0
The only reliable way to do this is by sending an AppleScript command to Finder.
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)'
You don’t have to use the Disk Utility GUI for this.
sudo diskutil repairPermissions /
Beginning with OS X El Capitan, system file permissions are automatically protected. It’s no longer necessary to verify or repair permissions with Disk Utility. (Source)
bless --mount "/path/to/mounted/volume" --setBoot
diskutil list
A continuous stream of file system access info.
sudo fs_usage
hdiutil create -volname "Volume Name" -srcfolder /path/to/folder -ov diskimage.dmg
If you’d like to encrypt the disk image:
hdiutil create -encryption -stdinpass -volname "Volume Name" -srcfolder /path/to/folder -ov encrypted.dmg
By default, you’ll be prompted for a password. You can automate that by piping in a password:
echo -n YourPassword | hdiutil create -encryption -stdinpass -volname "Volume Name" -srcfolder /path/to/folder -ov encrypted.dmg
This command applies to .iso, .img and .dmg images.
hdiutil burn /path/to/image_file
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
bless --folder "/path/to/mounted/volume/System/Library/CoreServices" --bootinfo --bootefi
hdiutil attach /path/to/diskimage.dmg
hdiutil detach /dev/disk2s1
Like the Disk Utility “Restore” function.
sudo asr -restore -noverify -source /path/to/diskimage.dmg -target /Volumes/VolumeToRestoreTo
defaults write com.apple.dock persistent-others -array-add '{ "tile-data" = { "list-type" = 1; }; "tile-type" = "recents-tile"; }' && \
killall Dock
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}' && \
killall Dock
Global setting whether Dock icons should bounce when the respective application demands your attention.
# Enable (Default)
defaults write com.apple.dock no-bouncing -bool true && \
killall Dock
# Disable
defaults write com.apple.dock no-bouncing -bool false && \
killall Dock
defaults delete com.apple.dock && \
killall Dock
Use your touchpad or mouse scroll wheel to interact with Dock items. Allows you to use an upward scrolling gesture to open stacks. Using the same gesture on applications that are running invokes Exposé/Mission Control.
# Enable
defaults write com.apple.dock scroll-to-open -bool true && \
killall Dock
# Disable (Default)
defaults write com.apple.dock scroll-to-open -bool false && \
killall Dock
The float number defines the show/hide delay in ms.
defaults write com.apple.Dock autohide-delay -float 0 && \
killall Dock
# Enable
defaults write com.apple.dock showhidden -bool true && \
killall Dock
# Disable
defaults write com.apple.dock showhidden -bool false && \
killall Dock
Supported formats are plain text, rich text (rtf) and Microsoft Word (doc/docx).
textutil -convert html file.ext
sudo chmod -RN /path/to/folder
chflags hidden /path/to/folder/
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Show All
defaults write com.apple.finder AppleShowAllFiles true
# Restore Default File Visibility
defaults write com.apple.finder AppleShowAllFiles false
sudo chflags -R nouchg /path/to/file/or/folder
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
chflags nohidden ~/Library
defaults write .GlobalPreferences NSNavRecentPlacesLimit -int 10 && \
killall Finder
Makes possible to see Finder menu item “Quit Finder” with default shortcut <kbd>Cmd</kbd> + <kbd>Q</kbd>
# Enable
defaults write com.apple.finder QuitMenuItem -bool true && \
killall Finder
# Disable (Default)
defaults write com.apple.finder QuitMenuItem -bool false && \
killall Finder
Useful if you’re on an older Mac that messes up the animation.
# Disable
defaults write NSGlobalDomain NSScrollAnimationEnabled -bool false
# Enable (Default)
defaults write NSGlobalDomain NSScrollAnimationEnabled -bool true
# Disable
defaults write -g NSScrollViewRubberbanding -bool false
# Enable (Default)
defaults write -g NSScrollViewRubberbanding -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true && \
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Hide Icons
defaults write com.apple.finder CreateDesktop -bool false && \
killall Finder
# Show Icons (Default)
defaults write com.apple.finder CreateDesktop -bool true && \
killall Finder
# Show
defaults write com.apple.finder ShowPathbar -bool true
# Hide (Default)
defaults write com.apple.finder ShowPathbar -bool false
Possible values: WhenScrolling
, Automatic
and Always
.
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
# Show
defaults write com.apple.finder ShowStatusBar -bool true
# Hide (Default)
defaults write com.apple.finder ShowStatusBar -bool false
Sets default save target to be a local disk, not iCloud.
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
defaults write com.apple.finder NewWindowTarget -string "PfLo" && \
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
Sets size to ‘medium’.
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
Avoids creation of .DS_Store
and AppleDouble files.
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
Avoids creation of .DS_Store
and AppleDouble files.
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
If multiple windows are open, it chooses the top-most one.
cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')"
open https://github.com
open README.md
You can open applications using -a
.
open -a "Google Chrome" https://github.com
open /path/to/folder/
open .
To clear font caches for all users, put sudo
in front of this command.
atsutil databases -removeUser && \
atsutil server -shutdown && \
atsutil server -ping
Please see this file.
# Status
defaults read /Library/Preferences/com.apple.Bluetooth ControllerPowerState
# Enable (Default)
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 1
# Disable
sudo defaults write /Library/Preferences/com.apple.Bluetooth ControllerPowerState -int 0 && \
sudo killall -HUP blued
networksetup -listallhardwareports
pmset -g batt | egrep "([0-9]+\%).*" -o --colour=auto | cut -f1 -d';'
pmset -g batt | egrep "([0-9]+\%).*" -o --colour=auto | cut -f3 -d';'
system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p'
system_profiler SPDisplaysDataType | grep Resolution
sysctl -n machdep.cpu.brand_string
# Status
defaults read /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled
# Enable (Default)
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -int 1
# Disable
defaults write /Library/Preferences/com.apple.driver.AppleIRController DeviceEnabled -int 0
Prevent sleep for 1 hour:
caffeinate -u -t 3600
sudo pmset -g
sudo pmset displaysleep 15
sudo pmset sleep 30
sudo systemsetup -getcomputersleep
sudo systemsetup -setcomputersleep 60
sudo systemsetup -setcomputersleep Never
sudo systemsetup -setrestartfreeze on
Play iOS charging sound when MagSafe is connected.
# Enable
defaults write com.apple.PowerChime ChimeOnAllHardware -bool true && \
open /System/Library/CoreServices/PowerChime.app
# Disable (Default)
defaults write com.apple.PowerChime ChimeOnAllHardware -bool false && \
killall PowerChime
# Disable
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false
# Enable (Default)
defaults write -g NSAutomaticSpellingCorrectionEnabled -bool true
# Show Status
defaults read -g NSAutomaticSpellingCorrectionEnabled
Disable the default “press and hold” behavior.
# Enable Key Repeat
defaults write -g ApplePressAndHoldEnabled -bool false
# Disable Key Repeat
defaults write -g ApplePressAndHoldEnabled -bool true
Sets a very fast repeat rate, adjust to taste.
defaults write NSGlobalDomain KeyRepeat -int 0.02
afconvert input.mp3 ringtone.m4r -f m4af
Uses “Alex” voice, a plain UTF-8 encoded text file for input and AAC output.
say -v Alex -f file.txt -o "output.m4a"
sudo nvram SystemAudioVolume=" "
osascript -e 'set volume output muted true'
osascript -e 'set volume 4'
You can play all audio formats that are natively supported by QuickTime.
afplay -q 1 filename.mp3
say 'All your base are belong to us!'
defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen 1
# Disable
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array-add "-NoMulticastAdvertisements"
# Enable (Default)
sudo defaults write /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist ProgramArguments -array "/usr/sbin/mDNSResponder" "-launchd"
sudo ipconfig set en0 DHCP
ipconfig getpacket en0
sudo dscacheutil -flushcache && \
sudo killall -HUP mDNSResponder
sudo scutil --set ComputerName "newhostname" && \
sudo scutil --set HostName "newhostname" && \
sudo scutil --set LocalHostName "newhostname" && \
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "newhostname"
Switch between network locations created in the Network preference pane.
# Status
scselect
# Switch Network Location
scselect LocationNameFromStatus
ping -o github.com
traceroute github.com
# Enable remote login
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
# Disable remote login
sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist
This outputs all applications currently using port 80.
sudo lsof -i :80
dig +short myip.opendns.com @resolver1.opendns.com
networksetup -setairportnetwork en0 WIFI_SSID WIFI_PASSWORD
Create a symbolic link to the airport command for easy access:
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/local/bin/airport
Run a wireless scan:
airport -s
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}'
ipconfig getifaddr en0
defaults read /Library/Preferences/SystemConfiguration/com.apple.airport.preferences | grep LastConnected -A 7
Exchange SSID with the SSID of the access point you wish to query the password from.
security find-generic-password -D "AirPort network password" -a "SSID" -gw
networksetup -setairportpower en0 on
cancel -a -
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true && \
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Show Status
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate
# Enable
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
# Disable (Default)
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /path/to/file
spctl --add /path/to/Application.app
spctl --remove /path/to/Application.app
tr -dc A-Za-z0-9_ < /dev/urandom | head -c 20 | pbcopy
open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
# Status
defaults read com.apple.screensaver askForPasswordDelay
# Enable (Default)
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Disable (Integer = lock delay in seconds)
defaults write com.apple.screensaver askForPasswordDelay -int 10
# Status
defaults read com.apple.screensaver askForPassword
# Enable
defaults write com.apple.screensaver askForPassword -int 1
# Disable (Default)
defaults write com.apple.screensaver askForPassword -int 0
srm /path/to/file
srm -r /path/to/folder/
srm -rf /path/to/complete/destruction
find . -type f -name '*.DS_Store' -ls -delete
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
The -i
modifier makes the search case insensitive.
locate -i *.jpg
# Enable AirDrop over Ethernet and on Unsupported Macs
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
# Enable (Default)
defaults remove com.apple.NetworkBrowser DisableAirDrop
# Disable
defaults write com.apple.NetworkBrowser DisableAirDrop -bool YES
osascript /path/to/script.scpt
diff -qr /path/to/folder1 /path/to/folder2
sudo reboot
sudo poweroff
sw_vers
How long since your last restart.
uptime
cat whatever.txt | pbcopy
pbpaste | textutil -convert txt -stdin -stdout -encoding 30 | pbcopy
pbpaste | expand | pbcopy
pbpaste > whatever.txt
pbpaste | sort | uniq | pbcopy
If FileVault is enabled on the current volume, it restarts the system, bypassing the initial unlock. The command may not work on all systems.
sudo fdesetup authrestart
# Status
sudo fdesetup status
# Enable
sudo fdesetup enable
# Disable (Default)
sudo fdestatus disable
sudo sysdiagnose -f ~/Desktop/
sudo kextstat -l
sudo kextload -b com.apple.driver.ExampleBundle
sudo kextunload -b com.apple.driver.ExampleBundle
Please see this file.
To be independent of OS X version, this relies on locate
to find lsregister
. If you do not have your locate
database built yet, do it.
sudo $(locate lsregister) -kill -seed -r
sudo defaults write /Library/Preferences/com.apple.loginwindow LoginwindowText "Your text"
sudo purge
# One time
vm_stat
# Table of data, repeat 10 times total, 1 second wait between each poll
vm_stat -c 10 1
# Disable
launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist && \
killall -9 NotificationCenter
# Enable (Default)
launchctl load -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist
qlmanage -p /path/to/file
# Status
sudo systemsetup -getremoteappleevents
# Enable
sudo systemsetup -setremoteappleevents on
# Disable (Default)
sudo systemsetup -setremoteappleevents off
# Enable
dsenableroot
# Disable
dsenableroot -d
# Status
nvram boot-args
# Enable
sudo nvram boot-args="-x"
# Disable
sudo nvram boot-args=""
Takes a screenshot as JPEG after 3 seconds and displays in Preview.
screencapture -T 3 -t jpg -P delayedpic.jpg
Sets location to ~/Desktop
.
defaults write com.apple.screencapture location ~/Desktop && \
killall SystemUIServer
Sets format to png
. Other options are bmp
, gif
, jpg
, jpeg
, pdf
, tiff
.
defaults write com.apple.screencapture type -string "png"
defaults write com.apple.screencapture disable-shadow -bool true && \
killall SystemUIServer
Date and time remain unchanged.
defaults write com.apple.screencapture name "Example name" && \
killall SystemUIServer
installer -pkg /path/to/installer.pkg -target /
sudo softwareupdate -ia
Set to check daily instead of weekly.
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
sudo softwareupdate -l
This should only be done for testing purposes or unmanaged clients. To use network-wide, either correctly set up DNS along with Apple SUS service and bind your clients via OpenDirectory. Alternatively, use Reposado together with correct network DNS settings to make resolution transparent. Margarita looks nice to have as well.
# Use own SUS
sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate CatalogURL http://su.example.com:8088/index.sucatalog
# Reset to Apple SUS
sudo defaults delete /Library/Preferences/com.apple.SoftwareUpdate CatalogURL
# Disable
mdutil -i off -d /path/to/volume
# Enable (Default)
mdutil -i on /path/to/volume
mdutil -E /path/to/volume
mdfind -name 'searchterm'
mdls /path/to/file
Reboot while holding <kbd>Cmd</kbd> + <kbd>R</kbd>, open the Terminal application and enter:
csrutil disable && reboot
Reboot while holding <kbd>Cmd</kbd> + <kbd>R</kbd>, open the Terminal application and enter:
csrutil enable && reboot
sudo systemsetup -listtimezones
sudo systemsetup -settimezone Europe/Berlin
# Status
sudo systemsetup getusingnetworktime
# Enable (Default)
sudo systemsetup setusingnetworktime on
# Disable
sudo systemsetup setusingnetworktime off
Rings the terminal bell (if enabled) and puts a badge on it.
tput bel
Install the latest version and set as current users’ default shell:
brew install bash && \
sudo echo $(brew --prefix)/bin/bash >> /etc/shells && \
chsh -s $(brew --prefix)/bin/bash
Install the latest version and set as current users’ default shell:
brew install fish && \
echo $(brew --prefix)/bin/fish | sudo tee -a /etc/shells && \
chsh -s $(brew --prefix)/bin/fish
Install the latest version and set as current users’ default shell:
brew install zsh && \
sudo sh -c 'echo $(brew --prefix)/bin/zsh >> /etc/shells' && \
chsh -s $(brew --prefix)/bin/zsh