logoalt Hacker News

Show HN: A shell-native cd-compatible directory jumper using power-law frecency

15 pointsby jghubyesterday at 10:20 AM2 commentsview on HN

I have used this tool privately since 2011 to manage directory jumping. While it is conceptually similar to tools like z or zoxide, the underlying ranking model is different. It uses a power-law convolution with the time series of cd actions to calculate a history-aware "frecency" metric instead of the standard heuristic counters and multipliers.

This approach moves away from point-estimates for recency. Most tools look only at the timestamp of the last visit, which can allow a "one-off" burst of activity to clobber long-term habits. By convolving a configurable history window (typically the last 1,000+ events), the score balances consistent habits against recent flukes.

On performance: Despite the O(N) complexity of calculating decay for 1,000+ events, query time is ~20-30ms (Real Time) in ksh/bash, which is well below the threshold of perceived lag.

I intentionally chose a Logical Path (pwd -L) model. Preserving symlink names ensures that the "Name" remains the primary searchable key. Resolving to physical paths often strips away the very keyword the user intends to use for searching.


Comments

zahlmantoday at 2:39 AM

Sorry, there's a lot here about the technical implementation details but much less I can understand about the problem being solved. What exactly do you mean by "manage"? What happens differently when you use this command, versus when you use built-in `cd`?

Leftiumtoday at 1:57 AM

I plan to use frecency in my bookmarking app.

Although you don't have any problems with lag, it is possible to efficiently compute frecency in O(1) complexity

> But with an additional trick, no recomputation is necessary. The trick is to store in the database something with units of date...

Full details: https://wiki.mozilla.org/User:Jesse/NewFrecency#Efficient_co...