Note: I'm new to zoxide and also recently found out about git worktrees.
Using zoxide with git worktrees is great. Being able to do z <branch-name> and instantly cd into that worktree feels super clean.
Moving to a worktree
~ $: z feature-branch
~/feature-branch $:
# Great, we're in the feature-branch worktree as we intended.
Moving within a worktree
That being said, I'm still having trouble when it comes to cd'ing into directories within a given worktree.
1. From worktree root
Consider the case where you're in your feature-branch worktree, and want to jump into it's test directory. This is more challenging, as illustrated below:
~/feature-branch $: z test
~/master/test $:
# not what we usually want- we're taken to the test directory in the master worktree
Unlike what we intended, we're almost always taken to the test directory in the master worktree because it almost always has a higher ranking than any newly created worktree. This could be solved by #468.
2. From any subdirectory in a worktree (not necessarily it's root)
~/feature-branch/test $: z src
~/master/src $:
# not what we usually want- we're taken to the `src` directory in the master worktree also because of it's higher score
Unlike the example above, this use case is not in scope for #468. Some possible areas to explore for a solution:
_ZO_EXCLUDE_DIRS. Perhaps we can use this to exclude other worktrees if we are in one.
?
I'm still not sure what's the best approach to take here. Ideally, the solution would look something like:
When we are in any worktree, we want zoxide to rank it higher than any of it's counterparts.
Any advice for a good approach to tackle this issue? I'm aware that this issue has multiple solutions- most of which possibly lie outside zoxide's scope. I'm just looking to be pointed in the right direction as I'm not sure which layer the logic should be inserted at.
I'm also curious about any general ideas or solutions other folks have implemented when dealing with multiple directories that tend to have a very similar shape, git worktrees or otherwise.
Workaround:
Currently, this is what I use:
Use zoxide to cd into a worktree
Use fzf's Alt+c to fuzzyfind+cd into any of it's subdirectories. This guarantees that only the subdirectories of the current pwd are in scope for the fuzzy search.
Using zoxide with git worktrees is great. Being able to do
z <branch-name>
and instantly cd into that worktree feels super clean.Moving to a worktree
Moving within a worktree
That being said, I'm still having trouble when it comes to cd'ing into directories within a given worktree.
1. From worktree root
Consider the case where you're in your
feature-branch
worktree, and want to jump into it'stest
directory. This is more challenging, as illustrated below:Unlike what we intended, we're almost always taken to the
test
directory in themaster
worktree because it almost always has a higher ranking than any newly created worktree. This could be solved by #468.2. From any subdirectory in a worktree (not necessarily it's root)
Unlike the example above, this use case is not in scope for #468. Some possible areas to explore for a solution:
_ZO_EXCLUDE_DIRS
. Perhaps we can use this to exclude other worktrees if we are in one.I'm still not sure what's the best approach to take here. Ideally, the solution would look something like:
When we are in any worktree, we want zoxide to rank it higher than any of it's counterparts.
Any advice for a good approach to tackle this issue? I'm aware that this issue has multiple solutions- most of which possibly lie outside zoxide's scope. I'm just looking to be pointed in the right direction as I'm not sure which layer the logic should be inserted at.
I'm also curious about any general ideas or solutions other folks have implemented when dealing with multiple directories that tend to have a very similar shape, git worktrees or otherwise.
Workaround:
Currently, this is what I use:
pwd
are in scope for the fuzzy search.