diff options
| author | EuAndreh <eu@euandre.org> | 2026-06-12 09:19:28 -0300 |
|---|---|---|
| committer | EuAndreh <eu@euandre.org> | 2026-06-12 09:19:28 -0300 |
| commit | 46fd0362bce11d709e5efe6d540358533985d363 (patch) | |
| tree | f77d2ed33c4f3fb6e85353e436efca4e19028f73 /doc/remembering.pt.1.in | |
| parent | rm .tdrc COPYING (diff) | |
| download | remembering-46fd0362bce11d709e5efe6d540358533985d363.tar.gz remembering-46fd0362bce11d709e5efe6d540358533985d363.tar.xz | |
Rewrite remembering in Go
The shell pipeline (sed | sort | tee | awk | sort | cut | "$@"
plus the cut | uniq | awk profile rewrite) becomes a single static
binary with the same observable behaviour, pinned by the original
ranking.sh, signals.sh and cli-opts.sh suites, now aimed at
remembering.bin:
- the profile keeps the exact on-disk format, COUNT profile TEXT,
byte-sorted with new picks appended at 1 and offered-but-never-
picked entries persisted at 0;
- the menu stays count-descending with byte-order ties, stdin
alone defines what is offered, and duplicate profile lines sum
for ranking but collapse to the highest count on rewrite, as
sort | uniq -f1 did;
- the wrapped command's exit status is forwarded as-is (128+sig
for signal deaths), its stderr passes through, and an empty pick
learns nothing;
- the profile rewrite stays atomic via .tmp plus rename.
Per the house CLI conventions, -h/-V/--help/--version are gone
(the manpage is the documentation; bad options print the usage on
stderr and exit 2), and getopts-style attached option arguments
(-pNAME) are not accepted any more --- no script in the wild used
them.
The project layout follows rot: raw go tool compile/link Makefile,
mkdeps.sh-generated deps.mk, white-box unit suite, fuzz target
over the profile parse/serialize roundtrip, functional pick
roundtrip, a 1M-line ranking benchmark, and a single English
asciidoc manpage absorbing the old .5 page; the po4a/aux release
machinery goes away.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'doc/remembering.pt.1.in')
| -rw-r--r-- | doc/remembering.pt.1.in | 231 |
1 files changed, 0 insertions, 231 deletions
diff --git a/doc/remembering.pt.1.in b/doc/remembering.pt.1.in deleted file mode 100644 index 76b179d..0000000 --- a/doc/remembering.pt.1.in +++ /dev/null @@ -1,231 +0,0 @@ -.\"******************************************************************* -.\" -.\" This file was generated with po4a. Translate the source file. -.\" -.\"******************************************************************* -.TH REMEMBERING 1 @DATE@ "remembering @VERSION@" - - -.SH NAME - -remembering \- sort list from \fISTDIN\fP using past choices as weight. - - -.SH SYNOPSYS - -\fBremembering\fP \fB\-p\fP \fIPROFILE\fP \fB\-c\fP \fICOMMAND\fP - - -.SH DESCRIPTION - -\fBremembering\fP takes a command that chooses an option as its behaviour, such -as \fBfzf\fP(1) or \fBdmenu\fP(1), and \fIremembers\fP what option is chosen, and as -it is used, will put the most used choices at the beginning of the list. - -\fBremembering\fP reads from STDIN and writes to STDOUT. It expects STDIN to -be sorted. - - -.SH OPTIONS - -.TP -\fB\-c\fP \fICOMMAND\fP -The \fICOMMAND\fP to be executed, reading from standard input (STDIN). - -.TP -\fB\-p\fP \fIPROFILE\fP -The name of the \fIPROFILE\fP where to look up and store raking data. - -.TP -\fB\-h\fP, \fB\-\-help\fP -Show short help text. - -.TP -\fB\-V\fP, \fB\-\-version\fP -Show version number. - - -.SH EXAMPLES - -List current directory and feed it to \fBfzf\fP(1) via \fBremembering\fP: - -.RS -.nf -$ ls | remembering \-p fzf\-ls \-c fzf -.fi -.RE - - -Lists all executables available in \fI$PATH\fP, and feed those to \fBdmenu\fP(1) -via \fBremembering\fP, and execute with \fBsh\fP(1) the choice picked: - -.RS -.nf -$ dmenu_path | remembering \-p dmenu\-exe \-c 'dmenu' | sh -.fi -.RE - -.P -Successive invocations will put the frequent choices at the beginning. - -.SS "Simulation of an interactive session" - -Below is a simulation of an interactive session, comparing the usage of -plain \fBfzf\fP(1) against composing it with \fBremembering\fP: - -.RS -.nf -$ mkdir \-p example/ -$ cd example/ -$ touch a b c d e -$ ls -a b c d e -$ ls | fzf -.fi -.RE - -We begin creating a sample directory called "\f(CRexample/\fR", we cd into -it and create 5 empty files: a, b, c, d and e. - -\f(CRls\fR can list the directory for us, in this case in alphabetical -order. - -When we pipe the output of \f(CRls\fR into \fBfzf\fP(1), we are give given its -prompt to pick one option: - -.RS -.nf - e - d - c - b -> a - 5/5 -> -.fi -.RE - -Here \fBfzf\fP(1) lists the items it gets from \fISTDIN\fP in the order that it -was given, and starts at the first one, "a". - -Once we type "d" and press return, the output of \fBfzf\fP(1) is the choice: - -.RS -.nf -$ ls | fzf -d -.fi -.RE - -Now if we run the same command again, we'll be given the same options, in -the same order: - -.RS -.nf -$ ls | fzf - - e - d - c - b -> a - 5/5 -> - -$ ls | fzf -d -.fi -.RE - -\fBfzf\fP(1) is doing what it is told to: making a prompt with the options -given to it from \fISTDIN\fP, in the order it was given. - -In order to have our past choices show up in the beginning of the list, we -can compose \fBfzf\fP(1) with \fBremembering\fP: - -.RS -.nf -$ ls | remembering \-p tutorial\-example \-c 'fzf' - - e - d - c - b -> a - 5/5 -> - -$ ls | remembering \-p tutorial\-example \-c 'fzf' -d -.fi -.RE - -So far we get the exact same behaviour, but saying extra things. We tell -\fBremembering\fP that we want this specific \fIPROFILE\fP to be called -"\f(CRtutorial\-example\fR", and we give \fBremembering\fP the \f(CR'fzf'\fR -command to be ran. - -From now on if we run the exact same command again, \fBremembering\fP will -\fIremember\fP that the last choice was "d", and put it in the beginning of the -list, which \fBfzf\fP(1) happily displays in the order it was given: - -.RS -.nf -$ ls | remembering \-p tutorial\-example \-c 'fzf' - - e - c - b - a -> d - 5/5 -> - -$ ls | remembering \-p tutorial\-example \-c 'fzf' -d -.fi -.RE - -This time the "d" option was already the first one, and we can just press -return to get it as the output value from the command. - -This example used \fBfzf\fP(1) as the \fICOMMAND\fP given to \fBremembering\fP, but -you can give to the \fB\-c\fP option anything that reads from \fISTDIN\fP, picks a -line and writes to \fBSTDOUT\fP. - - -.SH "SEE ALSO" - -\fBremembering\fP(5) - - -.SH AUTHORS - -.MT eu@euandre.org -EuAndreh -.ME -and contributors. - - -.SH BUGS - -.IP \(bu -Report bugs to the -.MT ~euandreh/public\-inbox@lists.sr.ht -mailing list -.ME . -Use the subject "\f(CR[remembering] BUG or TASK: -<description>\fR". -.IP \(bu -Browse bugs -.UR https://euandreh.xyz/remembering/TODOs.html -online -.UE . -.IP \(bu -.UR https://euandreh.xyz/remembering/en/ -Homepage -.UE . -.IP \(bu -.UR https://lists.sr.ht/~euandreh/public\-inbox?search=%5Bremembering%5D -Comments and discussions -.UE . |
