Detailed comparison of different hook options #142
-
Sorry to annoy you with such simple issues. But the documentation is not too extensive and I did not look into the code myself so far. PS: Does it make sense to cache the initialization? That was recommended for |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments
-
@weilbith the default hook is I personally prefer the The advantage of using the
Not really, since the zoxide binary does most of the work. The only thing it does at shell startup is set up a few aliases. On zsh, zoxide generates 79 lines of code (not counting blank lines/comments), which is barely anything to process. |
Beta Was this translation helpful? Give feedback.
-
Thank you. :🙏 |
Beta Was this translation helpful? Give feedback.
-
Not that I mistrusted your statement, but out of curiosity I did a quick performance test. The result: |
Beta Was this translation helpful? Give feedback.
-
That does make sense, since the startup time of a Linux binary is of the order of a millisecond. 1.9ms of extra startup time is usually not very significant. As long as you're doing caching with a version check, there should be no problem with it. It'd be nice if you could share how you're caching it, so that others who might be interested are able to do so too. As a side note, if you're interested in tweaking zoxide for maximum performance, you might want to build zoxide locally using cargo install --path . --target x86_64-unknown-linux-musl |
Beta Was this translation helpful? Give feedback.
-
I'm confused. My result clearly showed that doing caching is slower than working without a cache. So it does not make sense to share it. ^^
I think |
Beta Was this translation helpful? Give feedback.
-
I misread - this is what I get for using GitHub on my phone. Are you calling
Most executable files depend on a library called |
Beta Was this translation helpful? Give feedback.
-
Yes that makes sense. [[ ! -s "$ZOXIDE_INIT_CACHE_FILE" ]] && zoxide init zsh >| "$ZOXIDE_INIT_CACHE_FILE"
source "$ZOXIDE_INIT_CACHE_FILE"
So why is this not the default option for the distributed binary builds? 🤔 Sorry for abusing this issue. But there is still no messaging option in GitHub and I think it is not worth to open an issue for that. And if it should be relevant for other users, they still should be able to find it with the repository search. So I wanted to get some version of Lets say that is given: $ zoxide query --list --score key
20 /foo/bar/key
4 /bar/foo/key Let's give this a try: $ zoxide query /bar/foo key
/foo/bar/key I would have expected that the last query returns |
Beta Was this translation helpful? Give feedback.
-
I don't believe Cargo provides a way to set Regarding the distributed binaries - I'm not the best person to ask, as I don't package zoxide myself. Rather, that is done by some fantastic maintainers who do a far better job of keeping things upto date than I ever could! However, from what I've seen, packaging usually involves a script that at some point calls Of course, one could write a script to pick the That said, I do make
If it's not doing that, it's a bug. Keywords are matched in order, so this shouldn't be happening. I tried something similar on my own system and it worked correctly, so if you could give me an exact sequence of commands that reproduce this behaviour, ( |
Beta Was this translation helpful? Give feedback.
-
Thanks for the exhaustive answer! 🙏 Okay awkward. I tried to come up with such an example. But it works as you say. So I need to share more "private" infos, since there is definitely a scenario on my PC that does not work. So here is the exact example the question was originated from: $ zoxide query --list --score dapp
8 /home/thore/projects/brainbot-projects/repositories/raiden/light-client-test/raiden-dapp
1 /home/thore/projects/brainbot-projects/repositories/raiden/light-client/raiden-dapp
$ zoxide query /home/thore/projects/brainbot-projects/repositories/raiden/light-client dapp
/home/thore/projects/brainbot-projects/repositories/raiden/light-client-test/raiden-dapp Just to have some small context, there is a repository called |
Beta Was this translation helpful? Give feedback.
-
Haha yes, I understand now. Just add a - zoxide query /home/thore/projects/brainbot-projects/repositories/raiden/light-client dapp
+ zoxide query /home/thore/projects/brainbot-projects/repositories/raiden/light-client/ dapp |
Beta Was this translation helpful? Give feedback.
-
Oh wow. That was easy. |
Beta Was this translation helpful? Give feedback.
-
Without the slash, the keyword matches both directory names, so it picks the one with the higher score. Once you add the slash, it needs to match the slash at the end of the directory in the path:
|
Beta Was this translation helpful? Give feedback.
-
Ah I got it. Now I also see the obvious difference to the example case. Makes totally sense. xD |
Beta Was this translation helpful? Give feedback.
@weilbith the default hook is
pwd
and usually works great for most people. Your intuition is correct -pwd
increases the score of a directory whenever you cd into it, andprompt
increases the score with every command.pwd
is more efficient, since it is called less often, but I wouldn't worry about that - zoxide is quite fast, and doesn't cause any slowdown there.I personally prefer the
pwd
hook, because it intuitively makes more sense to me. If I have a directory that I cd into once every morning and use for the rest of the day without ever closing the terminal, that's not a very important directory compared to one I have to cd into and out of 100 times a day (even if it's just a tempora…