rupa / z

z - jump around
Do What The F*ck You Want To Public License
16.39k stars 1.17k forks source link

Common root logic is ignored #289

Open tekumara opened 4 years ago

tekumara commented 4 years ago

Common: When multiple directories match all queries, and they all have a common prefix, z will cd to the shortest matching directory, without regard to priority. This has been in effect, if undocumented, for quite some time, but should probably be configurable or reconsidered.

When there's a common root, z chooses the shortest matching directory as I expect:

$ cat ~/.z
/Users/tekumara/code/setup|1244.42|1593232000
/Users/tekumara/code|223.405|1593230323

$ z code -l
common:    /Users/tekumara/code
5905186    /Users/tekumara/code
37359611   /Users/tekumara/code/setup

However, the common root logic isn't applied in the following case, which gives the surprising behaviour of choosing the more frequent directory:

$ cd ~/.vscode/extensions
$ cat ~/.z
/Users/tekumara/.vscode/extensions|1|1593232307
/Users/tekumara/code/setup|1247.42|1593232301
/Users/tekumara/code|223.405|1593230323

$ z code -l
59990      /Users/tekumara/.vscode/extensions
5782900    /Users/tekumara/code
37395675   /Users/tekumara/code/setup

I was still expecting /Users/tekumara/code to win, despite the addition of the vscode directory.

gschaffner commented 4 years ago

Seconded. Another example is

$ cat ~/.z
/home/ganden/vc/jlab/pydux|814.861|1593380312
/home/ganden/vc|202.221|1593372880
$ z -l vc
404.442    /home/ganden/vc
3267.44    /home/ganden/vc/jlab/pydux

but I would like z vc to take me to ~/vc.

Neno23 commented 3 years ago

⁉️❓❔.… olympus?