I see that you mentioned it is inspired by duti. I think may be adding a comparison on how it solves what it couldn’t would be beneficial.
From quick skim and memory it seems a notable one is url scheme association.
One problem I had with duti is to associate extensions automatically from a pre defined “table”. Automating that involves shell scripting[^1]. Also associating extension to softwares that hasn’t been installed. Another pain point is there’s two ways to associate and depending on different cases one is better than another.
I love that it’s a command line tool — I’ll try it soon.
I use OpenIn for this [1] (it’s paid, but a one-time purchase at a very reasonable price). It works with URLs too, supports “browser profiles”, and lets you create logic using JavaScript (e.g., do X if the filename contains Y, or do Z if a modifier key is pressed).
It works really well and even has the ability to “fix” what external apps have changed. I plan to use this on new Macs to reconstruct my app associations and rules.
I do wish the rules were defined in plain text files — sometimes it’s hard to follow the logic through the UI and the way it handles things.
Another comment mentions Hammerspoon (which I used in the past — it was very nice). Maybe I can rebuild part of my current setup with it.
Would you consider adding support for domain-specific overrides (e.g., open *.notion.site links with Chrome but other URLs with Safari) in future versions?
show comments
goranmoomin
This is a bit tangent, but does anyone know how to block an app from ever deciding to become a file handler on macOS?
Every time I install Chrome on my machine (for testing purposes), macOS decides that Chrome is going to be the default file handler for a bunch of file associations, including HTML, WebP, and so on… and I have to figure out which was which for all of the mappings (which is super frustrating).
I can read Info.plist from the bundle of the specific app (in this case, Google Chrome) that declares all of the UTIs, and then figure out which file associations that Chrome has messed up, but I don’t know how to get the default file associations (if it was not Chrome) before it.
show comments
mlenz
Great to see this, thanks for sharing! Do you have plans to make it available in nixpkgs and potentially as a home-manager or nix-darwin module? Then I could add it to my config and have everything set up automatically.
show comments
FabHK
Typo: Declarative (think of declaration, not declarition)
show comments
dmwood
Shell dependencies for install?
Got:
bash-3.2# just package && mv dist/infat* /usr/local/bin/infat # Wildcard because output name includes platform
bash: just: command not found
show comments
hk1337
Is there a way to pass arguments or some other options? For example, TextEdit can be opened in plain text or rich text mode.
show comments
stinger
Running into this error - "Error: Failed to set default application: The file couldn’t be opened." This seems to be happening for extensions that I haven't opened yet (md, json, mailto, etc.) For a new laptop, this might not be available yet. Once I `touch` a file with those extensions, the config works!. FYI, I am using a config.toml file btw.
show comments
alkh
That's great, I've struggled with this problem a lot. To double-check, this essentially allows you to specify a default app that is being opened when you click on a file via Finder or via terminal's `open` program, correct? I haven't seen this exact clarification in README
show comments
timenova
This is amazing! I set a few extensions manually.
However, does anyone know a way to set all text-like documents to open with a single editor (for example Zed) on Mac? Even text files without any extensions?
show comments
deeThrow94
Oh this is very exciting! I do have a request, though—I want to list all file extensions an application can open, specifically so I can use this to ensure xcode isn't the default for anything but xcode-specific files.
show comments
gitroom
Pretty slick honestly, swapping machines on Mac is usually a pain for me so this feels like a lifesaver.
I see that you mentioned it is inspired by duti. I think may be adding a comparison on how it solves what it couldn’t would be beneficial.
From quick skim and memory it seems a notable one is url scheme association.
One problem I had with duti is to associate extensions automatically from a pre defined “table”. Automating that involves shell scripting[^1]. Also associating extension to softwares that hasn’t been installed. Another pain point is there’s two ways to associate and depending on different cases one is better than another.
[1]: https://github.com/ickc/bootstrapping-os-environments/blob/m...
I love that it’s a command line tool — I’ll try it soon.
I use OpenIn for this [1] (it’s paid, but a one-time purchase at a very reasonable price). It works with URLs too, supports “browser profiles”, and lets you create logic using JavaScript (e.g., do X if the filename contains Y, or do Z if a modifier key is pressed).
It works really well and even has the ability to “fix” what external apps have changed. I plan to use this on new Macs to reconstruct my app associations and rules.
I do wish the rules were defined in plain text files — sometimes it’s hard to follow the logic through the UI and the way it handles things.
Another comment mentions Hammerspoon (which I used in the past — it was very nice). Maybe I can rebuild part of my current setup with it.
[1] https://loshadki.app/openin4/
Would you consider adding support for domain-specific overrides (e.g., open *.notion.site links with Chrome but other URLs with Safari) in future versions?
This is a bit tangent, but does anyone know how to block an app from ever deciding to become a file handler on macOS?
Every time I install Chrome on my machine (for testing purposes), macOS decides that Chrome is going to be the default file handler for a bunch of file associations, including HTML, WebP, and so on… and I have to figure out which was which for all of the mappings (which is super frustrating).
I can read Info.plist from the bundle of the specific app (in this case, Google Chrome) that declares all of the UTIs, and then figure out which file associations that Chrome has messed up, but I don’t know how to get the default file associations (if it was not Chrome) before it.
Great to see this, thanks for sharing! Do you have plans to make it available in nixpkgs and potentially as a home-manager or nix-darwin module? Then I could add it to my config and have everything set up automatically.
Typo: Declarative (think of declaration, not declarition)
Shell dependencies for install? Got: bash-3.2# just package && mv dist/infat* /usr/local/bin/infat # Wildcard because output name includes platform bash: just: command not found
Is there a way to pass arguments or some other options? For example, TextEdit can be opened in plain text or rich text mode.
Running into this error - "Error: Failed to set default application: The file couldn’t be opened." This seems to be happening for extensions that I haven't opened yet (md, json, mailto, etc.) For a new laptop, this might not be available yet. Once I `touch` a file with those extensions, the config works!. FYI, I am using a config.toml file btw.
That's great, I've struggled with this problem a lot. To double-check, this essentially allows you to specify a default app that is being opened when you click on a file via Finder or via terminal's `open` program, correct? I haven't seen this exact clarification in README
This is amazing! I set a few extensions manually.
However, does anyone know a way to set all text-like documents to open with a single editor (for example Zed) on Mac? Even text files without any extensions?
Oh this is very exciting! I do have a request, though—I want to list all file extensions an application can open, specifically so I can use this to ensure xcode isn't the default for anything but xcode-specific files.
Pretty slick honestly, swapping machines on Mac is usually a pain for me so this feels like a lifesaver.