Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] filter_mode is "directory" but zsh-autosuggestions are global #1769

Closed
cohml opened this issue Feb 23, 2024 · 6 comments
Closed

Comments

@cohml
Copy link

cohml commented Feb 23, 2024

Sorry to pollute the issue space with this one which is probably particular to me. But it's killing me and I'm not sure how else to get definitive answers.

So far as I can tell, my system is completely up to date with respect to both atuin and zsh-autosuggestions:

❯ atuin --version
atuin 18.0.1
❯ git -C zsh-autosuggestions pull
Already up to date.

Furthermore, my atuin config specifies "directory" as the filter mode:

❯ grep -E '^filter_mode' $ATUIN_CONFIG_DIR/config.toml
filter_mode = "directory"

Lastly, ZSH_AUTOSUGGESTIONS lists atuin as the first entry:

echo $ZSH_AUTOSUGGEST_STRATEGY
atuin history

Despite all this, when I begin to type a command in a directory, the completions zsh-autosuggestions provides seem to come from my global history.

autosuggestion_always_global

Why might zsh-autosuggestions not be utilizing atuin's "directory" history as per my filter_mode setting, despite what the atuin docs say?

And finally, just for good measure:

❯ zsh --version
zsh 5.9 (x86_64-apple-darwin23.0)

I have one other - partially-related - question, which I will tack on here to avoid further polluting the issue space.

I moved to atuin from per-directory-history, which can also toggle between global and directory modes like atuin.

When using the per-directory-history with directory mode enabled, the up/down arrows would scroll through only those commands run from the given $PWD. Is it possible to enable the same using atuin? Because for me, although atuin opens in "directory" mode, up/down scrolling seems to pull from my global history.

Apologies if this is already addressed somewhere!

Note

I know it's possible to open atuin with the up arrow keybinding, but this isn't what I'm asking.

After running atuin init with --disable-up-arrow, I'm wondering if it's possible to still apply my filter_mode settings to filter commands when up/down arrowing.

@arcuru
Copy link
Contributor

arcuru commented Feb 26, 2024

To your first question, atuin has no suggestions so zsh is looking at your second option - pulling from your zsh history. Feel free to disable that if that's what you'd prefer.

To your second unrelated question: if you disable the up arrow for atuin, then the up/down scrolling pulls from your zsh history and not from atuin. There has been consideration for adding up/down scrolling as a new feature but it is not yet implemented. See #798 if you want to set it up yourself.

@cohml
Copy link
Author

cohml commented Feb 26, 2024

To your first question, atuin has no suggestions so zsh is looking at your second option - pulling from your zsh history.

The example above used mktemp -d just as an extreme case. However I have seen this happen even in directories I use all the time. Shouldn't that not be happening given the configurations I've shown?

There has been consideration for adding up/down scrolling as a new feature but it is not yet implemented.

Awesome! I've read through that discussion and it sounds like there's clear enthusiasm for it. Would love to see it implemented!

@cohml
Copy link
Author

cohml commented Feb 26, 2024

Ya know what, as I putz around for other examples to share, I'm starting to wonder if I have been imagining things all along...

There have definitely been cases where the autosuggestions did not seem per-directory, but then I just opened atuin and quickly moved on with my life without investigating further.

Now that I'm taking the time to carefully curate some unambiguous examples, I'm struggling to actually reproduce the problem I described at the outset!

I will close this issue for now and reopen if and only if I am no longer seeing smoke and mirrors. Sorry for the goose chase!

@cohml cohml closed this as not planned Won't fix, can't repro, duplicate, stale Feb 26, 2024
@cohml
Copy link
Author

cohml commented Feb 26, 2024

@arcuru Okay, I think I've seen through the smoke and mirrors, but your earlier reply may inadvertently cleared it up! Let me just confirm...

You said:

atuin has no suggestions so zsh is looking at your second option - pulling from your zsh history.

With the mktemp -d example I showed, atuin had no suggestions because I was in a fresh dir from which I had never run ANY commands. Thus, len(atuin_history) == 0. According to you, this is why zsh-autosuggestions pulls from zsh history.

However, it seems that zsh-autosuggestions will also pull from zsh history even if len(atuin_history) > 0, provided that no directory commands match the prefix of what I'm typing out.

Consider this example (apologies for the production quality, apparently I'm not a great screenshotter):

example.mov

What I've tried to demonstrate are two scenarios:

  1. if the command I'm typing has a match in my directory history, zsh-autosuggestions suggests that match, as expected
  2. if the command I'm typing doesn't match anything I've run in that PWD before, zsh-autosuggestions searches global history instead.

My initial mktemp -d example was just an extreme case of scenario (2), because obviously no commands will have matches when typing in a brand new directory.

Have I understood how it all works? If so, I suppose my confusion comes from the fact that with the per-directory-history plugin, scenario (2) would result in no suggestions at all. So that was the behavior I naively expected of atuin.

@cohml cohml reopened this Feb 26, 2024
@arcuru
Copy link
Contributor

arcuru commented Feb 26, 2024

if the command I'm typing doesn't match anything I've run in that PWD before, zsh-autosuggestions searches global history instead.

Yes, that is what I meant when I said

atuin has no suggestions so zsh is looking at your second option - pulling from your zsh history

To get the behavior you're expecting you should change $ZSH_AUTOSUGGEST_STRATEGY to only include atuin.

To be fair, it does seem a little bit strange with how we've setup the fallback to go to your zsh history by default...

@cohml
Copy link
Author

cohml commented Feb 26, 2024

Okay great, thanks so much for clarifying!

In the end, while I in fact was not imagining things (phew!), I was misunderstanding exactly how ZSH_AUTOSUGGEST_STRATEGY works.

So it seems that only my brain/expectations need to be updated here, not atuin :)

Thanks again!

@cohml cohml closed this as completed Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants