fresort(1) | General Commands Manual | fresort(1) |
fresort - sort lines by their usage frecency
fresort [options...] <frecency_file>
fresort is a filter which sorts lines passed to its input based on their usage frecency from a frecency_file (see FRECENCY section below). It puts lines which are not found in frecency file, followed by the lines ordered by their current frecency.
fresort also maintains frecency file and updates appropriate frecencies when used with --update switch, which counts as a usage "hit". In time, frecency files can grow with many historical entries which are no longer relevant. To preven this, fresort limits their number to the quantity controlled with --limit switch. On top of that, entries with frecencies approaching 0 are removed as well.
Input lines can be matched against their parts, similar to awk(1). This is controlled with --field and --field-separator switches. Even if only a certain field is compared, fresort always prints the whole original input line.
Frecency is a measure which combines usage frequency and recency. It prioritises entries which were used few times recently over the ones used many times long ago.
fresort uses exponential decay method to age frecency of entries in a frecency file. With this method one controls a haf-life of frecency, which is a time after which frecency decreases by half of its initial value. Half-life is controlled with --half-life (or short -t) switch.
fresort doesn't store half-life in frecency file so it can be changed freely in every invocation of fresort. However, using different half-life times updates and input filtering can yield unexpected results of decaying certain entries faster than than the other ones.
-l, --list
-t, --half-time=HALF_TIME
-n, --field=N
-F, --field-separator=SEP
--reverse
--limit=N
--with-score
--version
-h, --help
#!/bin/sh file=$(find . -type f -name '*.txt' | fresort ~/.cache/files.fre | fzf --no-sort --tac) fresort -u "${file}" ~/.cache/files.fre vim "${file}"
$ cat /etc/passwd | fresort ~/.cache/shells.fre -F ':' -n 7
Michał Góral <dev@goral.net.pl>
Source code: https://git.goral.net.pl/fresort.git
2024-12-21 |