ajeetdsouza / zoxide

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

Zoxide doesn't understand zsh's named directories (~) #396

Open FFdhorkin opened 2 years ago

FFdhorkin commented 2 years ago

I'm looking for an easy way to make ambiguous directories play nice with zoxide without needing to use a different tool. There are quite a few zsh plugins for "bookmarking" or "favoriting" folders, but I don't want to have to remember to use a different command to jump to those folders - I want to use the familiar z syntax.

zsh has a built in feature called named directories that should be able to solve this, but zoxide doesn't seem to consider them unless you explicitly put the ~.

For example, I currently am working in an environment where I have to use some awkward naming conventions. I'm not sure whether zoxide or I hate these conventions more :P

I've anonymized these paths to make my point without using the actual names (this is the exact number and structure they actually have, though. Thankfully, the folders under **/ant_*/**/* will be going away soon). I'm not surprised zoxide doesn't really know what to do with these - to the human eye, it's also pretty easy to misread them.

but we're talking the difference between something along the lines of LASERService and LSRService, and it just gets worse from there. These are all source code folders:

/some/shared/path/laser_service/src/LASERService/src
/some/shared/path/laser_service/src/LASERServiceLibrary/src
/some/shared/path/laser_service/src/LSRNameServiceLibrary/src
/some/shared/path/laser_service/src/LASERServiceCdk/src
/some/shared/path/laser_service/src/LASERServiceImageBuild/src
/some/shared/path/laser_service/src/LASERServiceTests/src
/some/shared/path/ant_laser_service/src/LASERService/src
/some/shared/path/ant_laser_service/src/LASERServiceLibrary/src
/some/shared/path/ant_laser_service/src/LSRNameServiceLibrary/src
/some/shared/path/ant_laser_service/src/LASERServiceCDK/src
/some/shared/path/ant_laser_service/src/LASERServiceImageBuild/src
/some/shared/path/ant_laser_service/src/LASERServiceTests/src
/some/shared/path/laser_web_app/src/LASERWebApp/src
/some/shared/path/laser_web_app/src/LASERWebAppCDK/src
/some/shared/path/laser_web_app/src/LASERWebAppImageBuild/src
/some/shared/path/laser_web_app/src/LASERWebAppTests/src
/some/shared/path/laser_web_app/src/LSRWebAppLibrary/src
/some/shared/path/laser_web_app/src/MMWebAppIntegrationTests/src
/some/shared/path/cdk/src/LASERCommonCDK/src
/some/shared/path/cdk/src/LASERCommonConfig/src
/some/shared/path/cdk/src/LASERServiceCDK/src

Have you reached semantic saturation looking at that list? I certainly did itemizing all the folders!

To wrangle this a bit, I've created some of those ~ named directory aliases by adding this to my .zshrc (note that since LASER isn't the actual app name, I'm not shadowing ls... which would be a horrible idea):

ls=/some/shared/path/laser_service
als=/some/shared/path/ant_laser_service
lwa=/some/shared/path/laser_web_app

Now I can at least go z ~ls ser to go to /some/shared/path/laser_service/src/LASERService z ~als ser to go to /some/shared/path/ant_laser_service/src/LASERService etc.

but these error out with zoxide: no match found, and I can't see why they zoxide can't figure it out, even with COMPLETE_ALIASES enabled: z ls ser z als ser

TL;DR: please make zoxide search zsh's ~ named directories without requiring the tilde! It might not seem like much, but it's very easy to forget the tilde

FFdhorkin commented 2 years ago

As a potentially (un)related side note: when I'm in the ~ls folder, z ser jumps to ~als, rather than ~ls/src/LASERService.

Likewise, when I'm in the ~als, folder, z ser jumps to ~ls, rather than ~als/src/LASERService

I've tried various options of _ZO_FZF_OPTS with --tiebreak, but it doesn't seem to help. Surely a subfolder should be prioritized over another folder with a similar name?