From 04044c414647c8ce9c9be92e23d5a5247250d294 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1nos=20Ill=C3=A9s?= Date: Sat, 8 Apr 2023 11:53:32 +0200 Subject: [PATCH] Use XDG data directory for fish import (#851) * Use XDG data directory for fish import On MacOS, atuin was looking for fish history under "$HOME/Library/Application Support". Now atuin honors XDG_DATA_HOME, if set, and otherwise uses "$HOME/.local/share". * cargo fmt --------- Co-authored-by: Charles Gould --- atuin-client/src/import/fish.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atuin-client/src/import/fish.rs b/atuin-client/src/import/fish.rs index 7186537..e54ca73 100644 --- a/atuin-client/src/import/fish.rs +++ b/atuin-client/src/import/fish.rs @@ -19,7 +19,10 @@ pub struct Fish { /// see https://fishshell.com/docs/current/interactive.html#searchable-command-history fn default_histpath() -> Result { let base = BaseDirs::new().ok_or_else(|| eyre!("could not determine data directory"))?; - let data = base.data_local_dir(); + let data = std::env::var("XDG_DATA_HOME").map_or_else( + |_| base.home_dir().join(".local").join("share"), + PathBuf::from, + ); // fish supports multiple history sessions // If `fish_history` var is missing, or set to `default`, use `fish` as the session