Repository: atuinsh/atuin (language: rust)

Issue:
[Bug]: Error: Could not find history file. Try setting and exporting $HISTFILE
### What did you expect to happen?

Hello,
It's not really a bug as it's working as expected by I think we can improve it.
Context: I installed atuin on a new PC with a fresh Arch installation. Before the atuin installation, the only thing I did was to follow the zsh new user questionnaire. Then I did atuin login and atuin import zsh

I think atuin should import zsh history when it's the zsh default configuration.

### What happened?

```
❯ ssh mini
Last login: Sat Feb 15 16:58:55 2025 from 192.168.1.121
mini% echo $HISTFILE
/home/slamp/.histfile
mini% atuin import zsh
        Atuin
======================
          🌍
       🐘🐘🐘🐘
          🐢
======================
Importing history...
Importing history from zsh
Error: Could not find history file. Try setting and exporting $HISTFILE`

Location:
    crates/atuin-client/src/import/zsh.rs:38:27


mini% cat .zshrc
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000

setopt autocd extendedglob nomatch notify
bindkey -e
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '/home/slamp/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstall

eval "$(atuin init zsh --disable-up-arrow)"
```

Note: the following command works `export HISTFILE=~/.histfile  atuin import zsh` but the first impression is an error


### Atuin doctor output

```yaml
{
  "atuin": {
    "version": "18.4.0",
    "sync": {
      "cloud": false,
      "records": true,
      "auto_sync": true,
      "last_sync": "2025-02-15 16:07:54.190783889 +00:00:00"
    },
    "sqlite_version": "3.46.0"
  },
  "shell": {
    "name": "zsh",
    "default": "zsh",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Arch Linux",
    "arch": "x86_64",
    "version": "rolling",
    "disks": [
      {
        "name": "/dev/nvme0n1p3",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/nvme0n1p3",
        "filesystem": "btrfs"
      },
      {
        "name": "/dev/nvme0n1p1",
        "filesystem": "vfat"
      }
    ]
  }
}
```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct


Discussion / hints:
For a new user, zsh run zsh-newuser-install [(see Arch doc)](https://wiki.archlinux.org/title/Zsh#Initial_configuration)

https://github.com/zsh-users/zsh/blob/master/Functions/Newuser/zsh-newuser-install#L794

The default is `HISTFILE=$zdmsg/.histfile`, which correspond to `HISTFILE=~/.histfile`

The value `~/.histfile` is also documented in https://wiki.archlinux.org/title/XDG_Base_Directory 

**Proposal**
Add in [zsh.rs](https://github.com/atuinsh/atuin/blob/main/crates/atuin-client/src/import/zsh.rs#L28) ~/.histfile as candidate 

I can try to do the code modification, if there is a consensus.


Fix patch:
diff --git a/crates/atuin-client/src/import/zsh.rs b/crates/atuin-client/src/import/zsh.rs
index 5bc8fc16416..0778596781c 100644
--- a/crates/atuin-client/src/import/zsh.rs
+++ b/crates/atuin-client/src/import/zsh.rs
@@ -21,11 +21,12 @@ pub struct Zsh {
 fn default_histpath() -> Result<PathBuf> {
     // oh-my-zsh sets HISTFILE=~/.zhistory
     // zsh has no default value for this var, but uses ~/.zhistory.
+    // zsh-newuser-install propose as default .histfile https://github.com/zsh-users/zsh/blob/master/Functions/Newuser/zsh-newuser-install#L794
     // we could maybe be smarter about this in the future :)
     let user_dirs = UserDirs::new().ok_or_else(|| eyre!("could not find user directories"))?;
     let home_dir = user_dirs.home_dir();
 
-    let mut candidates = [".zhistory", ".zsh_history"].iter();
+    let mut candidates = [".zhistory", ".zsh_history", ".histfile"].iter();
     loop {
         match candidates.next() {
             Some(candidate) => {


Test patch: