zsh-snap
zsh-snap copied to clipboard
Aliases definitions executed by `znap eval` can mess up code later on
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?
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.
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
%
It turns out this is probably because I'm binding
zoxide
tocd
That is indeed the problem. After defining an alias for cd
, all code that is source
d 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?
@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.
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.