Show HN: Infat - macOS 声明式应用关联管理器
philocalyst / **infat ** Public
- Notifications You must be signed in to change notification settings
- Fork 1
- Star 54
一个命令行工具,用于在 macOS 上设置文件格式和 URL schemes 的默认打开方式
License
MIT license 54 stars 1 fork Branches Tags Activity Star Notifications You must be signed in to change notification settings
Additional navigation options
philocalyst/infat
main BranchesTags Go to file Code
Folders and files
Name| Name| Last commit message| Last commit date ---|---|---|---
Latest commit
History
90 Commits .github/workflows| .github/workflows Completions| Completions Sources| Sources .gitignore| .gitignore CHANGELOG.md| CHANGELOG.md LICENSE| LICENSE Package.swift| Package.swift README.md| README.md justfile| justfile View all files
Repository files navigation
Welcome to Infat
Infat 是一个超强大的、macOS 原生的 CLI 工具,用于声明式地管理文件类型和 URL scheme 的关联。 避免导航子菜单来设置默认浏览器或图像查看器的麻烦,以及每次获得新机器时都要执行此操作的痛苦。设置一次规则,并沉浸在您自己的聪明才智中,直到永远。夺回控制权,并将您的打开器绑定到您想要的任何东西。覆盖一切!谁会阻止你?
Summary
- 列出哪些应用程序打开给定的文件扩展名或 URL scheme
- 为文件扩展名或 URL scheme 设置默认应用程序
- 从 TOML 配置文件加载关联 (
[files]
和[schemes]
表) - 详细、可脚本化,非常适合高级用户和管理员
Get Started
首先安装 Infat — 跳转到下面的 Install 部分。
Tutorial
1. Listing Associations
# 显示 .txt 文件的默认应用程序
infat list txt
# 显示 .txt 文件的所有注册应用程序
infat list --assigned txt
2. Setting a Default Application
# 对 .md 文件使用 TextEdit
infat set TextEdit --file-type md
# 对 .json 文件使用 VSCode
infat set VSCode --file-type json
3. Binding a URL Scheme
# 对 mailto: 链接使用 Mail.app
infat set Mail --scheme mailto
4. Configuration
将 TOML 文件放置在 $XDG_CONFIG_HOME/infat/config.toml
(或传递 --config path/to/config.toml
),其中包含两个表:
[files]
md = "TextEdit"
html = "Safari"
pdf = "Preview"
[schemes]
mailto = "Mail"
web = "Safari"
不带参数运行以应用所有条目。
infat --config ~/.config/infat/config.toml
Design Philosophy
- Minimal & Scriptable Infat 是一个单二进制工具,可以在 shell 和自动化管道中很好地运行。
- macOS-First 利用原生
NSWorkspace
、Launch Services 和 UTType 进行强大的集成。 - Declarative Configuration TOML 支持允许您将关联与其它 dotfiles 一起进行版本控制。
Building and Debugging
您需要 just 和 Swift 5.9+:
# Debug build
just build
# Release build
just build-release
# Run in debug mode
just run "list txt"
# Enable verbose logging for troubleshooting
infat --verbose list pdf
Install
Homebrew
brew install philocalyst/tap/infat
From Source
git clone https://github.com/philocalyst/infat.git && cd infat
just package && mv dist/infat* /usr/local/bin/infat # Wildcard because output name includes platform
Changelog
有关更改的完整历史记录,请参见 CHANGELOG.md。
Libraries Used
Acknowledgements
- Inspired by duti
- Built with Swift, thanks to corporate overlord Apple’s frameworks
- Thanks to all contributors and issue submitters (One day!!)
License
Infat is licensed under the MIT License. Feel free to use, modify, and distribute!
About
A command line tool to set default openers for file formats and url schemes on macos
Resources
License
Stars
Watchers
Forks
Releases 6
v1.0.0 Latest Apr 24, 2025 + 5 releases
Packages 0
No packages published
Contributors 2
Languages
Footer
Footer navigation
You can’t perform that action at this time.