cantino / mcfly

Fly through your shell history. Great Scott!
MIT License
6.87k stars 177 forks source link

Storing configuration in XDG directories, if ~/.mcfly does not exist #124

Closed Awernx closed 2 years ago

Awernx commented 3 years ago

Hello @cantino! Per your suggestion on #121, I've created a pull request.

Code checks for existence of ~/.mcfly, and uses it if available. Otherwise,

  1. history.db is stored in XDG_DATA_DIR
  2. cache CSV is stored in XDG_CACHE_DIR

Code uses directories-next for XDG path computation.

Thanks!

Awernx commented 3 years ago

Have made the suggested changes

colemickens commented 2 years ago

This change looks good, I'd like to see it merged. mcfly currently stands aside ssh+gnupg+parallel as polluting my homedir and I am hoping to knock this one off the list. Thanks for mcfly and the change!

cantino commented 2 years ago

~/.mcfly feels like a good default to me, but maybe I'm old school? I'd definitely be fine with this being configurable with a setting, but I don't know how I feel about moving the default.

nfultz commented 2 years ago

~/.mcfly feels like a good default to me, but maybe I'm old school? I'd definitely be fine with this being configurable with a setting, but I don't know how I feel about moving the default.

If you are thinking of adding an environment variable to configure it, you may as well just piggyback off of $XDG_CONFIG_HOME - which is what this PR does.

Or continue to use ~/.mcfly, which is also still supported.

colemickens commented 2 years ago

Respectfully, this feels like a safe change, especially after reviewing the code:

Nearly every other greenfield Rust app follow xdg - bottom, helix, zellij, wezterm, alacritty, jj, joshuto, nu, pijul, etc... all respect XDG dirs. mcfly stands alone here; even zoxide follows it.

And, as of now, .mcfly and .mozilla are now the only thing left in my home dir, beyond the unmovable .ssh:

~
❯ exa -la
drwxr-xr-x  - cole  8 Mar 14:32 .cache
drwx------  - cole  8 Mar 14:26 .config
drwxr-xr-x  - cole 26 Nov  2021 .local
drwxr-xr-x  - cole  8 Mar 14:33 .mcfly
drwx------  - cole 26 Nov  2021 .mozilla
drwxr-xr-x  - cole  8 Mar 14:26 .ssh
drwxr-xr-x  - cole  7 Mar 01:09 code
drwxr-xr-x  - cole  8 Mar 13:58 downloads
drwxr-xr-x  - cole  8 Mar 14:10 Sync
lrwxrwxrwx 70 cole  8 Mar 14:26 .zshenv -> /nix/store/vzsbwrcq46mddx1ra29pwqlfzf2k9vm5-home-manager-files/.zshenv

Even Mozilla is finally fixing this after a 18+ year old open bug: https://bugzilla.mozilla.org/show_bug.cgi?id=259356

I'm not sure I consider mcfly special enough to be one of the last things dumping into my home directory.

cantino commented 2 years ago

To be replaced by https://github.com/cantino/mcfly/pull/244

cantino commented 2 years ago

https://github.com/cantino/mcfly/pull/244 has been merged

colemickens commented 2 years ago

Awesome, thank you @cantino and @Awernx

cantino commented 2 years ago

:+1: I'll get a new build out shortly.

cantino commented 2 years ago

https://github.com/cantino/mcfly/releases/tag/v0.6.0 released!