Sub topic 13
Change capture defaults with the defaults command
This chapter assumes you can open Terminal and run a command, and that you know where macOS saves screenshots by default. The earlier chapter on the Screenshot toolbar covered changing the save location through the interface. Here you will change the same settings, plus a few the toolbar does not offer, from the command line.
How the defaults command works
macOS stores user preferences in property list files, one per application or system component. The defaults command reads and writes those files. Screenshot settings live in the domain com.apple.screencapture. A domain is the name of one preference file.
The pattern is always the same:
defaults readshows a value.defaults writesets a value.defaults deleteremoves your value so the system default applies again.
The screenshot service runs inside a background process called SystemUIServer. It reads the preferences when it starts, so a changed value does not take effect until you restart that process with killall SystemUIServer. The system restarts it automatically within a moment.
Change the save location
Create the folder first. If the folder does not exist, captures may fail to save.
mkdir -p ~/Pictures/Screenshots
defaults write com.apple.screencapture location ~/Pictures/Screenshots
killall SystemUIServerTake a screenshot with Shift-Command-3 and check that the file appears in the new folder.
Change the file format
The default format is PNG, which is lossless and gives large files for photo-like content. JPEG produces smaller files with some quality loss.
defaults write com.apple.screencapture type jpg
killall SystemUIServerOther accepted values include png, pdf, tiff, and gif. An unsupported value is ignored and you get PNG.
Other useful settings
| Key | Example value | Effect |
|---|---|---|
| `disable-shadow` | `-bool true` | Removes the drop shadow from window captures |
| `show-thumbnail` | `-bool false` | Turns off the floating thumbnail |
| `name` | `"Shot"` | Replaces the "Screenshot" prefix in file names |
| `include-date` | `-bool false` | Leaves the date and time out of file names |
Each key follows the same write-then-restart pattern. For example, this removes window shadows:
defaults write com.apple.screencapture disable-shadow -bool true
killall SystemUIServerCheck and undo your changes
Read a value back to confirm it:
defaults read com.apple.screencapture locationIf the key has never been set, the command reports that the pair does not exist. To return to the system default, delete the key and restart:
defaults delete com.apple.screencapture type
killall SystemUIServerCommon errors
- The change has no effect. You probably skipped
killall SystemUIServer. - Screenshots still go to the Desktop. The folder path may be misspelled or the folder may not exist. Run
lson the path to check. - A boolean setting does nothing. Without the
-boolflag,defaultsstores the value as a string. Include the flag for true/false keys. - Your changes are lost. A managed Mac may have settings enforced by an administrator, which override your own.
Exercise
You ran defaults write com.apple.screencapture type jpg, but your next screenshot is still a PNG. What did you most likely forget, and what command fixes it?
Show answer
You did not restart SystemUIServer, which reads the preference only when it starts. Run killall SystemUIServer, then take another screenshot.
Exercise
How do you undo a custom screenshot location and return to the system default?
Show answer
Run defaults delete com.apple.screencapture location, then killall SystemUIServer. Screenshots go back to the Desktop.