atuin: [Bug]: wrong item selected from history

What did you expect to happen?

macOS 15.4.1 and atuin 18.5.0

when I press ctrl+r to find history, select item from history wrong item is pasted to the command prompt.

Can’t always reproduce. Usually I do this quickly, ctrl+r, select what I need (by searching, etc) and press enter. Few times noticed, wrong command was pasted into prompt from history.

This happened on at least two occasions just today, which already drove me a bit crazy. When specifically tried, can’t reproduce.

What happened?

Wrong record was pasted into command prompt from history. let’s say I wanted to select line from history where I meant to rerun command to copy file, but instead rm -rf /path which I didn’t mean to delete was run.

Atuin doctor output

$ atuin doctor
Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

{
  "atuin": {
    "version": "18.5.0",
    "sync": null,
    "sqlite_version": "3.46.0"
  },
  "shell": {
    "name": "zsh",
    "default": "zsh",
    "plugins": [
      "atuin"
    ],
    "preexec": "built-in"
  },
  "system": {
    "os": "Darwin",
    "arch": "arm64",
    "version": "15.4.1",
    "disks": [
      {
        "name": "REDACTED",
        "filesystem": "apfs"
      },
      {
        "name": "REDACTED",
        "filesystem": "apfs"
      },
      {
        "name": "REDACTED",
        "filesystem": "apfs"
      }
    ]
  }
}

Code of Conduct

  • I agree to follow this project’s Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 19
  • Comments: 53 (21 by maintainers)

Most upvoted comments

18.6.0 stable is out now!

a pre-release is out with the fix:

https://github.com/atuinsh/atuin/releases/tag/18.6.0-beta.1

atuin update --prerelease

I hit the bug again, and tried #2715, and it seems to fix it. I did an omz reload (from oh-my-zsh), so I don’t know if that might’ve fixed it separately since it’s a per-shell issue, but I’ll keep running that and see if it occurs again.

@monyxie I got it fixed! I can no longer reproduce the bug! 🥳

cargo install \
  --git https://github.com/curtisbelt-forks/atuin.git \
  --branch zsh-select-bug \
  --root ~/.atuin \
  --force

Adding the --root ~/.atuin to the install command worked.

atuin status
Atuin v18.5.0 - Build rev bead125743546236d72083e95450de10b1c470e5

That’s the correct hash from my fork 👍🏻

@ellie Apologies for not realizing my binary wasn’t actually changed all this time! Looks like @monyxie and I are both confirmed cases of solving this bug with this very small patch: https://github.com/atuinsh/atuin/compare/main...curtisbelt-forks:atuin:zsh-select-bug (credit to @monyxie for figuring that out).

Thank you! That patch is included in #2715 (that I’ve been asking people to test 😅), so I’ll get that one merged. @BinaryMuse has been running it for a week now without the issue coming back.

Thanks for all the input everyone!

I also have the patch installed and encountered the issue again and then resolved it using omz reload so also confirming the patch is not resolving the issue.

@ellie

atuin store rebuild history worked for me and fixed the issue with the specific item that had trouble.

Im on atuin 18.5.0 mac 15.4.1 zsh 5.9

The cargo command should show you the path to the atuin binary near the end of its output.

    ...
    Finished `release` profile [optimized] target(s) in 1m 48s
   Replacing /home/monyxie/.local/share/cargo/bin/atuin
    Replaced package `atuin v18.5.0 (file:///home/monyxie/code/atuin#1706c1d8)` with `atuin v18.5.0 (file:///home/monyxie/code/atuin#1706c1d8)` (executable `atuin`)

You need to make sure that directory is in your PATH and precedes ~/.atuin/bin/.

I did some more testing.

  • Downgrading omz back to a commit from 1 year ago - issue persists.
  • Disabling omz altogether - issue goes away.
  • Downgrading atuin to 18.3.0 - issue goes away.

I then ran a bisect and it pointed to this commit. I was able to make the issue go away with this:

diff --git a/crates/atuin/src/shell/atuin.zsh b/crates/atuin/src/shell/atuin.zsh
index 63b20b47..e75e7559 100644
--- a/crates/atuin/src/shell/atuin.zsh
+++ b/crates/atuin/src/shell/atuin.zsh
@@ -71,8 +71,8 @@ _atuin_search() {
         then
             LBUFFER=${LBUFFER#__atuin_accept__:}
             zle accept-line
-        else
-            zle .infer-next-history && zle .up-history
         fi
     fi
 }

@curtisbelt im on plain zsh 5.9 not using oh my zsh.

Terminal is iterm2

After upgrading to build from #2706 and reloading omz don’t recall seeing this bug, also using Ghostty, but v 1.1.3.

@ellie I wish that was the case! I can rule that out completely as I’ve restarted my computer between installing the patch and seeing the bug.

For good measure I just ran this again:

 cargo install --git https://github.com/atuinsh/atuin --branch ellie/disable-zsh-changes
    Updating git repository `https://github.com/atuinsh/atuin`
     Ignored package `atuin v18.5.0 (https://github.com/atuinsh/atuin?branch=ellie%2Fdisable-zsh-changes#b96bc5f9)` is already installed, use --force to override

which confirms it’s installed.

Thanks @curtisbelt! So far it does seem to be only zsh users, and potentially even omz. Does suggest that #2715 might resolve it. Are you able to test the patch?

cargo install --git https://github.com/atuinsh/atuin --branch ellie/disable-zsh-changes

With which shell?

{
  "atuin": {
    "version": "18.5.0",
    "sync": {
      "cloud": true,
      "records": true,
      "auto_sync": true,
      "last_sync": "2025-04-20 17:55:54.576626153 +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/nvme0n1p2",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/nvme0n1p4",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/sdc1",
        "filesystem": "xfs"
      },
      {
        "name": "/dev/sdb1",
        "filesystem": "xfs"
      }
    ]
  }
}

To clarify my earlier comment regarding 18.4.0 – downgrading seems to prevent the issue from occurring on new entries, as devusb said, but it doesn’t seem to fix entries that are already broken, at least immediately.

will do. fwiw it feels like it just started recently (maybe with 18.5) – I hadn’t noticed it before this week, but seems like it’s like 2-3 times a day now in different contexts across different machines.

I’m having the same issue. My far fetched guess is that my multiple terminals are syncing, and then, the history in older terminals loses sync with history indexes.

When this issue happens to me I’m usually working on two different terminals side by side. After a while, the older terminal begins having the issue. Now, if I open a new terminal, the issue is gone.

I’ll post a video the next time it happens. Also, I’m going to try #2706.