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

Aliases definitions executed by znap eval can mess up code later on #211

Open
lazywei opened this issue Dec 26, 2022 · 5 comments
Open

Aliases definitions executed by znap eval can mess up code later on #211

lazywei opened this issue Dec 26, 2022 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@lazywei
Copy link

lazywei commented Dec 26, 2022

Describe the bug

When I add this line in my .zshrc

znap eval zoxide 'zoxide init zsh --cmd cd'

znap status gives the following errors:

~ ❯ znap status 
zoxide: zoxide: no match foundno match found

""zszsh-snap": hNo such file or directory- (os error a2u)t
osuggestions": No such file or directory (os error 2)
 zoxide: no match found
zoxide: no match found
 %                                                                  

Steps To Reproduce

As mentioned above

Expected behavior

znap status should be able to list the repos

Environment:

  • OS: macOS
  • Terminal: Kitty
  • Zsh version: 5.9
  • Repo version: 97e9904

Additional context

Errors are gone if I switch back to the plain eval

eval "$(zoxide init zsh --cmd cd)"

I wonder if this is because the way I'm using znap eval is incorrect and that leads to the zoxide not being correctly initialized?

@lazywei lazywei added the bug Something isn't working label Dec 26, 2022
@lazywei
Copy link
Author

lazywei commented Dec 26, 2022

It turns out this is probably because I'm binding zoxide to cd, changing to below resolves the issue

znap eval zoxide 'zoxide init zsh --cmd j'

Not sure why though. Feel free to close this issue if you think this is by-design or sort of expected.

@acsezen
Copy link

acsezen commented Feb 2, 2023

I have the same problem. Switching back to eval "$(zoxide init zsh --cmd cd)" didn't fix my problem.

❯ znap status
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
"site-functions": No such file or directory (os error 2)
"zsh-autosuggestions": No such file or directory (os error 2)
 "zsh-history-substring-search": No such file or directory (os error 2)
"zsh-syntax-highlighting": No such file or directory (os error 2)
"zsh-completions": No such file or directory (os error 2)
"zsh-snap": No such file or directory (os error 2)
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
zoxide: no match found
     % 

@marlonrichert
Copy link
Owner

marlonrichert commented Feb 27, 2023

It turns out this is probably because I'm binding zoxide to cd

That is indeed the problem. After defining an alias for cd, all code that is sourced will use this new alias for every cd statement, instead of the builtin cd command.

Try moving znap eval zoxide 'zoxide init zsh --cmd cd' to the very end of your .zshrc. Does that solve the issue?

@lazywei
Copy link
Author

lazywei commented Feb 27, 2023

@marlonrichert the problem still exists though. The workaround I'm using right now is dogin

znap eval zoxide 'zoxide init zsh --cmd j'
alias cd="j"

this way i'm able to using cd as z though the zi still maps to ji but that's good enough for me.

@marlonrichert
Copy link
Owner

I think I figured out a workaround that is otherwise useful, too: Znap could defer all alias definitions until the command line has been loaded.

@marlonrichert marlonrichert self-assigned this Feb 28, 2023
@marlonrichert marlonrichert changed the title znap status doesn't work when using znap eval for Zoxide Aliases definitions executed by znap eval can mess up code later on May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants