ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
22.12k stars 537 forks source link

`z <directory>` will jump to entry in database whereas `z <directory>\` will jump to subdirectory <directory> is not Working #728

Closed KAGEYAM4 closed 7 months ago

KAGEYAM4 commented 7 months ago

From the readme->

z foo              # cd into highest ranked directory matching foo
z foo/             # cd into relative path

But if there is a directory named foo in current directory, it jumps to that instead of highest ranked directory matching foo

ajeetdsouza commented 7 months ago

This is intended behaviour, z first acts as a cd command and falls back to jumping to another directory.

You can work around this by deliberately not using the full directory name, e.g. z fo.

KAGEYAM4 commented 7 months ago

This is intended behaviour, z first acts as a cd command and falls back to jumping to another directory.

You can work around this by deliberately not using the full directory name, e.g. z fo.

Do you think the above scenario would be useful, consider this case -> when we type something on the command line and hit TAB, then we are trying to auto-complete using what's present in current-directory -

ajeetdsouza commented 7 months ago

I understand where you're coming from, but any "smart" feature that is based on heuristics can (by definition) never be perfect. While there will always be small use-cases that don't work as expected, it will work correctly most of the time.

I'd encourage you to try it for a few days and see if you get used to it. Otherwise, one can easily create a custom z command without this behaviour. For example, on zsh:


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

function z() {
  cd "$(zoxide query -- "$@")"
}
KAGEYAM4 commented 7 months ago

Thank you.