agkozak / zsh-z

Jump quickly to directories that you have visited "frecently." A native Zsh port of z.sh with added features.
MIT License
2.02k stars 76 forks source link

Feature: "zshz --add $dir" should increase its rank by at least 1 #57

Closed zachriggle closed 2 years ago

zachriggle commented 3 years ago

It seems like increasing the rank by at least 1 for existing directories would be a good idea.

I've got a few hundred directories tracked by zshz, many are all at score 1, and executing any number of commands in them (interactive or in a loop) doesn't seem to increase the score at all.

It would seem that doing e.g.

for i in {1..100}; do zshz --add $PWD; done

Should bump up the score to at least 3, but it does not :(.

agkozak commented 3 years ago

That's a bug. Give me a little while and I'll fix it. Thanks, @zachriggle!

agkozak commented 3 years ago

OK. Give your no-age branch a pull and see if that fixes it.

zachriggle commented 3 years ago

Here's my commit history with the merge:

$ glg -n 10
*   d04e99a - (HEAD -> master) Merge branch 'no-age' of https://github.com/agkozak/zsh-z (3 minutes ago) - Zach Riggle
|\
| *   ce15243 - (upstream/no-age) Merge branch 'bugfix' into no-age (71 minutes ago) - Alexandros Kozak
| |\
| | * 5c13e5d - rank was not incrementing during --add (72 minutes ago) - Alexandros Kozak
| * |   5a144c7 - Merge branch 'develop' into no-age (2 days ago) - Alexandros Kozak
| |\ \
| | * | 986f088 - Documentation (2 days ago) - Alexandros Kozak
| | * | 7f275aa - (upstream/add-relative-paths) Path fix for Cygwin/MSYS2 (2 days ago) - Alexandros Kozak
| | * | efcba57 - Add relative paths (but fix for MSYS/Cygwin/etc.) (2 days ago) - Alexandros Kozak
| | |/
| | * b1055fb - Zdharma link (13 days ago) - Alexandros Kozak
| | * 25f780f - Zdharma links (13 days ago) - Alexandros Kozak
| | * 9eb7b94 - Sort completions by rank, not alphabetically (4 weeks ago) - Alexandros Kozak

It doesn't look like it worked 😢

$ pwd
/Users/zachriggle/zshz-add-test

$ z -l zshz-add-test
2          /Users/zachriggle/zshz-add-test

$ zshz --add $PWD/a

$ zshz --add $PWD/b

$ z -l zshz-add-test
common:    /Users/zachriggle/zshz-add-test
1          /Users/zachriggle/zshz-add-test/a
1          /Users/zachriggle/zshz-add-test/b
2          /Users/zachriggle/zshz-add-test

$ zshz --add $PWD/a

$ zshz --add $PWD/a

$ zshz --add $PWD/a

$ z -l zshz-add-test
common:    /Users/zachriggle/zshz-add-test
1          /Users/zachriggle/zshz-add-test/b
2          /Users/zachriggle/zshz-add-test
2          /Users/zachriggle/zshz-add-test/a

$ zshz --add $PWD/a

$ z -l zshz-add-test
common:    /Users/zachriggle/zshz-add-test
1          /Users/zachriggle/zshz-add-test/b
2          /Users/zachriggle/zshz-add-test
2          /Users/zachriggle/zshz-add-test/a

$ wc -l ~/.z
     646 /Users/zachriggle/.z
agkozak commented 3 years ago

$ z -l zshz-add-test common: /Users/zachriggle/zshz-add-test 1 /Users/zachriggle/zshz-add-test/a 1 /Users/zachriggle/zshz-add-test/b 2 /Users/zachriggle/zshz-add-test

I'm a little baffled that you get such small numbers when using z -l; that's what I'd expect to see with z -lr.

Here's what it looks like on my end right now -- isn't this what you're looking for?

asciicast

agkozak commented 3 years ago

Normally, when you do z -l (as opposed to z -lr), you should see very big numbers to the left. They don't represent the rank field in the database, but rather a relationship between the rank field and the age field. A brand-new addition to the database will be score tens of thousands at first.

agkozak commented 3 years ago

@zachriggle Is this working for you now?

zachriggle commented 2 years ago

Things seem to be working better now, thanks!