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

[Feature Request] Jumping to children of current working directory #459

Open
leoshimo opened this issue Sep 15, 2022 · 6 comments
Open

[Feature Request] Jumping to children of current working directory #459

leoshimo opened this issue Sep 15, 2022 · 6 comments

Comments

@leoshimo
Copy link

leoshimo commented Sep 15, 2022

Feature request to add additional shell commands for jumping to children for working directory, similar to jc in autojump.

WDYT about bringing this to zoxide?

Happy to take this task on.

@ajeetdsouza
Copy link
Owner

Sure! I'd suggest a feature that works this way:

  • If the first parameter of zoxide query is ~, then all results should start with $HOME.
  • If the first parameter of zoxide query is ., then all results should start with $PWD.

You'd be able to use z . foo and it would only match a subdirectory.

@Blonteractor
Copy link
Contributor

Got a working backend for this. Right now I added a zw command which cds into a subdirectory by passing the --workingdir flag to zoxide query.

@ajeetdsouza ajeetdsouza mentioned this issue Oct 13, 2022
Closed
@Blonteractor
Copy link
Contributor

I got it working by making it a different command in the shell scripts, zw, don't know enough bash to implement checking the first parameter to zoxide query and triggering the respective behavior but it should be trivial, sound good?

@ajeetdsouza
Copy link
Owner

This behaviour should be triggered within Rust rather than within Bash, since it would be common to all 8 shells supported by zoxide.

@Blonteractor
Copy link
Contributor

Aight made a pull request

@mtalexan
Copy link

mtalexan commented Jan 29, 2024

I'd argue this should also be the default behavior for the z and zi commands, and a different command should be used for cases where the current directory context isn't relevant.

The z.lua tool (and for some cases z and autojump) seems to have understood that the following is the order for how common actions are:

  1. Going to sub folder of the current
  2. Going to the functional root (e.g. git root, hg root, etc) above the current
  3. Going to a parent directory by name match
  4. Going to an equivalent directory to the current, where some portion of the parent path is swapped for something else
  5. (not handled by them) A recent folder unrelated to the current one.

Option 5 already has a poor manual jump list in Linux with pushd, popd, dirs, ~1/, ~2/, etc.

Currently I would estimate 98% of use cases a jump command wants to do something relative to their current folder (up, down, or over). Only a small number of cases want to jump to unrelated folders. Unfortunately, Zoxide currently only supports jumping to unrelated folders, and custom functions would need to be written to enable jumping to folders relative to the current (e.g. a custom function that automatically inserts the current path as the first search term).

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

4 participants