Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[query] please support a --basedir parameter to filter roots #944

Open
jessefarinacci opened this issue Dec 2, 2024 · 3 comments
Open

Comments

@jessefarinacci
Copy link

I often want to run zoxide query --interactive in a large project and have the results all be at the project root where I'm invoking zoxide, not just the ones zoxide thinks are the most popular.

I propose a new --basedir [path] parameter to the query subcommand. If user passes --all we can error out or just preference one or the other. With --list and --interactive it will filter all results for having the same fully qualified path prefix specified by --basedir parameter, with the $CWD being the default value.

The query subcommand already supports an --exclusion mechanism for filtering. This new option to effectively invert that logic will also be valuable. Thanks!

@azaleacolburn
Copy link

azaleacolburn commented Mar 25, 2025

@ajeetdsouza This is something that could be done pretty easily by adding a field and builder method to StreamOptions, then a filter method to Stream.

@jessefarinacci This is a really small thing, but I'm not sure that the --basedir option you described would invert the logic of --exclude as the former would only include child paths, which the latter excludes the given path only, allowing child paths. Am I misunderstanding what you're describing, or am I describing the feature correctly?

@jessefarinacci
Copy link
Author

Hi, I'm proposing a feature of --basedir [optional specified path parameter, or $cwd by default] argument to allow users to filter zoxide suggestions that start with the same root path. Maybe some examples will be helpful, imagine a server log directory broken down roughly by timestamp part directories:

❯ zoxide query --list
/tmp/zoxide/2025
/tmp/zoxide/2025/02
/tmp/zoxide/2025/03
/tmp/zoxide
/tmp/zoxide/2025/02/05
/tmp/zoxide/2025/02/04
/tmp/zoxide/2025/03/01
/tmp/zoxide/2025/03/09
/tmp/zoxide/2025/03/17
/tmp/zoxide/2025/02/14
/tmp/zoxide/2025/02/02
/tmp/zoxide/2025/01/06
/tmp/zoxide/2025/01/05
/tmp/zoxide/2025/01/02
/tmp/zoxide/2025/01
/tmp/zoxide/2025/01/01
.......
❯ zoxide query --list --basedir /tmp/zoxide/2025/01
/tmp/zoxide/2025/01/06
/tmp/zoxide/2025/01/05
/tmp/zoxide/2025/01/04
/tmp/zoxide/2025/01/03
/tmp/zoxide/2025/01/02
/tmp/zoxide/2025/01
/tmp/zoxide/2025/01/01
........
❯ cd /tmp/zoxide/2025/02
❯ zoxide query --list --basedir
/tmp/zoxide/2025/02
/tmp/zoxide/2025/02/05
/tmp/zoxide/2025/02/04
/tmp/zoxide/2025/02/14
/tmp/zoxide/2025/02/09
/tmp/zoxide/2025/02/08
/tmp/zoxide/2025/02/06
/tmp/zoxide/2025/02/02
........

Also this should work with --interactive which would be incredibly useful too, and my selfish reason for wanting it, thanks :)

@azaleacolburn
Copy link

Perfect, the PR I opened should work exactly as outlined. Thank you so much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants