đ macOS Tricks
Dieser Inhalt ist noch nicht in deiner Sprache verfĂŒgbar.
A running collection of macOS hints: small tools and incantations that each solve one annoyance well, and are each too short to deserve their own page. Entries stand alone â read the one you need and ignore the rest.
duti â set default apps from the CLI
Section titled âduti â set default apps from the CLIâduti manages file-type â app associations. It does what Finderâs Open With â Change All⊠does, except scriptable, and therefore repeatable across machines.
Associations are per-user. Run it as the account whose defaults are
changing, not under sudo.
brew install duti# for another account: su - guidos -c 'brew install duti'Find the identifiers
Section titled âFind the identifiersâSetting an association takes two things: the appâs bundle ID, and the fileâs Uniform Type Identifier.
osascript -e 'id of app "Zed"' # app bundle IDmdls -name kMDItemContentType -r file.json # a file's UTIduti -x json # who currently handles .jsonSet the default
Section titled âSet the defaultâduti -s dev.zed.Zed public.json all # by UTIduti -s dev.zed.Zed jsonl all # by extension, for odd or dynamic typesduti -s abnerworks.Typora net.daringfireball.markdown allThe trailing argument is the role â all, viewer, or editor. Use all
unless thereâs a specific reason not to.
Common UTIs
Section titled âCommon UTIsâ| UTI | Extension |
|---|---|
public.json |
.json |
public.plain-text |
.txt |
net.daringfireball.markdown |
.md |
public.yaml |
.yaml, .yml |
public.shell-script |
.sh |
public.data |
fallback for unknown types |
Keep it in dotfiles
Section titled âKeep it in dotfilesâThe calls are idempotent, so a batch is safe to rerun and belongs with your dotfiles â a new machine then gets the same associations without a Finder session.
duti -s dev.zed.Zed public.plain-text allduti -s dev.zed.Zed public.yaml allduti -s dev.zed.Zed public.shell-script allChanges hit the LaunchServices database for the current user only, and take effect immediately â no restart, no logout. The Finder equivalent, one file type at a time, is âI â Open with â Change AllâŠ.