zoxide
zoxide copied to clipboard
Error message on non-directory argument
Hello, I was trying out zoxide when I ran into the following behavior:
When I run:
z <filename>
where filename is an actual file not a directory, the error message I get back from zoxide is:
"zoxide: no match found"
This same command with the bash cd:
cd <filename>
returns:
"bash: cd: ./reading: Not a directory"
It would be much nicer IMO if zoxide could return a similar error message, instead of the current one, as "no match found" could imply that the target doesn't exist, rather than it not being a directory.
my number 1 ask for a better cd would be to get to the directory that contains a file, rather than error
@Fil I'm not exactly sure how I feel about that. On the one hand it may make things smoother, but on the other, it can really cause problems and confusion. Imagine the following scenario:
dir1/ | dir2/ || myfile | diir2 | myfile
Imagine wanting to erase dir1/dir2/myfile:
cd dir1/dir2
But type instead:
cd dir1/diir2
And then:
rm myfile
In such a scenario, you might end up erasing the wrong file. I can conceive of other cases where this behavior would be problematic such as if a directory is replaced by a file and a non-updated script wreaks havoc in its parent dir.
For me an explicit error, though inconvenient in many cases, is definitely safer.