From 4f08e7febba8d024cbf583544a8cd563e02c3413 Mon Sep 17 00:00:00 2001 From: rupa Date: Wed, 12 Sep 2018 10:53:50 -0400 Subject: [PATCH] continuous frecency a curve that seems to fit original behavior pretty closely. h/t @dcervenkov --- z.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/z.sh b/z.sh index 22386b4..3e09f74 100644 --- a/z.sh +++ b/z.sh @@ -140,12 +140,9 @@ _z() { local cd cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" ' function frecent(rank, time) { - # relate frequency and time - dx = t - time - if( dx < 3600 ) return rank * 4 - if( dx < 86400 ) return rank * 2 - if( dx < 604800 ) return rank / 2 - return rank / 4 + # relate frequency and time + dx = t - time + return rank * (3.75/((0.0001 * dx + 1) + 0.25)) } function output(matches, best_match, common) { # list or return the desired directory