Hacker News new | ask | show | jobs
by bjackman 268 days ago
Does anyone know if zoxide has any fancy logic to ignore strings that appear in common prefixes?

For example I have a big ~/src dir where I keep all my code checkouts. If I type 'z src' intending to go to ~/src/foo/bar/src, will it be clever enough to realise that I am referring to the second instance of the string 'src'?

I currently use a Fish port of the original 'z'. It does ignore the common prefix of _all_ matches (so if I only ever used it within my ~/src tree, the problem would disappear) but after that binary exclusion it works exclusively on frecency.

2 comments

Adding to the other answer: You can also pass multiple keywords to zoxide and they are expected to match in order. So in your example, `z foo src` would reliably cd into `~src/foo/bar/src` even if `src/foo` has a higher visit frequency.
Ok what about when I have this

~/src/linux/linux

~/src/linux/stable

And I want to go to the first one? It doesn't have a unique sequence of keywords in it :/

Unless it recognises that if I type "z lin lin" I want the one where it appears twice?

I'm beginning to think my directory structure might just be toxic haha

You can think of it as replacing the space between words as wildcards, so `z lin lin` would indeed work to select the first one!
> I'm beginning to think my directory structure might just be toxic haha

Some tools have a hard time solving some problems when the problem is us.

Here's an idea that might work for you. Rename ~/src/linux_/ or something like that.
lacy https://crates.io/crates/lacy might be what you want
As far as I'm aware it keeps a history of the frequency you visit each directory so yes it will select the one you've visited more often (assuming you don't always start at the base one and work your way down).
No the issue is that the one I want _isnt_ the most recent. Because 90% of the directories I visit contain the string 'src'