I think I'll use this crate instead: https://crates.io/crates/etcetera
It's what `bat` uses. It follows the XDG standard everywhere except Windows.
I feel that this makes a lot of sense for CLI config files which the user is supposed to edit themselves. As someone pointed out in the thread above, Apple's default locations are more for files that are not supposed to be edited directly by the user.
Long thread here: https://github.com/dirs-dev/directories-rs/issues/47
Seems they won't support that.
While not the official Apple sanctioned place for config files, the standard on the command line for MacOS tends to be using the Linux style ~/.config for config files. Can we add support for using...
I need to add a config file to tracker. Debating myself a bit on what the location should be. For the data files, I am currently using a crate called "directories" which helps locate OS-dictated standard directories for such things.
But it's a bit annoying to have things in ~/Library/Application Support/tech.skagedal.tracker – following the macOS standard, rather then just ~/.tracker, or following the XDG standard ~/.config/tracker which seems to be quite common also on macOS for CLI apps.
Not sure why I just spent a good chunk of my day researching and putting together this answer on a 12 year old question (with multiple answers) on how to best parse an URL from a shell script.
I like my answer though.
I have url like: sftp://[email protected]/some/random/path I want to extract user, host and path from this string. Any part can be random length.