2024-01-23    2024-01-23    329 字  1 分钟

方法一:

  • 选中文件 -> 右键 -> get info -> open with(选择你需要设置的默认app)-> 点击 Change All

方法2:

  • 使用 duti 工具
  • dutis : duti 的一个交互工具(可选),注意: 目前仅支持安装到/Applactions 目录的app

安装

1
brew install duti

使用

1
2
3
4
5
6
7
8
duti -s <appBundleId> <UTI> all
# UTI: Uniform Type Identifier, 一般文件后缀对应的 文档类型
# appBundleID app的Bundle ID
# 你也可以这样设置,不过更推荐使用UTI来代替".xx"
duti -s <appBundleId> .后缀 all

# 查看当前后缀的默认文件
duti -x <后缀>

相关技巧

appBundle 查看方法

1
mdls -name kMDItemCFBundleIdentifier -r <app路径>

查看该app支持的文件后缀和类型

1
grep -A3 CFBundleTypeExtensions <app路径>

确认文件后缀对应的UTI

1
2
mdls -name kMDItemContentTypeTree /path/to/file
# 重点关注结尾和后缀名一样的一行

参考

  1. macOS 下如何批量更改默认应用?#7 - V2EX