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 <charles@gould.dev>
This commit is contained in:
János Illés 2023-04-08 11:53:32 +02:00 committed by GitHub
parent a72bf07453
commit 04044c4146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -19,7 +19,10 @@ pub struct Fish {
/// see https://fishshell.com/docs/current/interactive.html#searchable-command-history
fn default_histpath() -> Result<PathBuf> {
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