Corrigenda of the Hand
Corrigenda of the Hand reads your shell history and prints, as the corrigenda leaf at the back of a printed edition, the typing slips you keep correcting, each as "for X read Y" with the line of the file where it was first seen, its date when the file kept one, and how many times it recurs. Last on the page, nearest the cursor, it prints a block of alias lines that makes each slip stop costing a retype. Its real input is your own history file, read in place and never copied: zsh with EXTENDED_HISTORY, bash with or without HISTTIMEFORMAT, or plain one command per line, found from $HISTFILE, then the file for your $SHELL, then ~/.zsh_history or ~/.bash_history, or a path you give it. It needs Python 3 and nothing else; run it from this folder:
uv run corrigenda.py # the leaf for your own history; [HISTFILE] [-n N] also accepted
uv run corrigenda.py --aliases >> ~/.zshrc # only the alias block, for ~/.zshrc or ~/.bashrc
uv run python -m unittest -v # the checks
Only first words are ever printed, the slip and its correction: arguments are compared in memory and never output, logged or stored, nothing is written to disk and nothing leaves the machine. Paste the alias, use it, and run this again: a slip you now use without its correction more often than with it leaves the leaf.
e2e.sh runs every acceptance check of CARD.md on Linux with tmux, zsh, strace and script, typing into real shells, and keeps what it saw in out/; shots.py takes the screenshots in shots/ from a real tmux pane. BUILD.md records what was run and what it printed.
Not run: the top-row comparison of check 3. The build box's own ~/.bash_history holds no recurring slip, so its page stands as printed and has no row to compare; the tool's exit code and the absence of a traceback on that file were checked.
Fixtures
Every file in fixtures/ was written by a real interactive shell (bash 5.2.21, zsh 5.9, Linux), driven in tmux by e2e.sh in an empty directory, and copied byte for byte; each run of e2e.sh writes them again before the checks.
bash-plain.hist:HISTFILE=$(mktemp) bash --norc --noprofile -i, thengti status,git status,ls,gti status,git status,pwd,gti status,git status,exit.bash-plain-retired.hist: the same file after a secondHISTFILE=<same file> bash --norc --noprofile -i:alias gti='git',gti statusfour times,exit.bash-timestamped.hist:HISTTIMEFORMAT='%s ' HISTFILE=$(mktemp) bash --norc --noprofile -i, thengti status, 5 seconds,git status,ls,gti status, 5 seconds,git status,pwd,gti status, 301 seconds,git status,exit.bash-mixed.hist:HISTFILE=$(mktemp) bash --norc --noprofile -iwithgti status,git statustwice andexit, thenHISTTIMEFORMAT='%s ' HISTFILE=<same file> bash --norc --noprofile -iwithgti log,git log,exit.zsh-extended.hist:HISTFILE=$(mktemp) zsh -f -i, thensetopt EXTENDED_HISTORY RCS; SAVEHIST=1000typed first (-falso turns offRCS, and with it the save at exit),gti status,git status, a three-linefor i in 1 2; do/echo $i/done,echo 2×3(zsh writes the sign's second byte metafied, so the file is not UTF-8),gti status,git status,sl,ls,uname,sl,ls,exit.bash-secret.hist:HISTFILE=$(mktemp) bash --norc --noprofile -i, thengti push https://user:[email protected]/x.gitandgit push https://user:[email protected]/x.git, three times, thenexit.SECRET123is the planted string the privacy check looks for, not a credential; git stopped at "not a git repository" and sent nothing.bash-alias.hist:HISTFILE=$(mktemp) bash --norc --noprofile -i, thenalias ll='ls -l',ll38 times,llandlstwice,gerp -c bash /etc/shellsandgrep -c bash /etc/shellsthree times,gerp -c bash /etc/shellsandegrep -c bash /etc/shellsonce,exit.
Colophon
The fixtures were typed into real shells one key at a time by a script that makes no mistakes of its own, so it had to be told which ones to make.
normal is dead
Files
- README.md
- corrigenda.py
- e2e.sh
- fixtures/bash-alias.hist
- fixtures/bash-mixed.hist
- fixtures/bash-plain-retired.hist
- fixtures/bash-plain.hist
- fixtures/bash-secret.hist
- fixtures/bash-timestamped.hist
- fixtures/zsh-extended.hist
- out/c1-alias.txt
- out/c11-page.txt
- out/c11.rc
- out/c2-aliases.txt
- out/c2-page.txt
- out/c3-page.txt
- out/c3-stderr.txt
- out/c4-aliases.txt
- out/c4-page.txt
- out/c5-mixed.txt
- out/c5-timestamped.txt
- out/c5-zsh.txt
- out/c7-nocolor.txt
- out/c7-page.txt
- out/c7-pane.ans
- out/c7-pane.txt
- out/c7-pty.txt
- out/c8-err.txt
- out/c8-out.txt
- out/capture/bash-alias.hist
- out/capture/bash-mixed.hist
- out/capture/bash-plain-retired.hist
- out/capture/bash-plain.hist
- out/capture/bash-secret.hist
- out/capture/bash-timestamped.hist
- out/capture/zsh-extended.hist
- out/e2e.log
- out/screen-aliases-120.ans
- out/screen-aliases-46.ans
- out/screen-missing-120.ans
- out/screen-missing-46.ans
- out/screen-own-120.ans
- out/screen-own-46.ans
- out/screen-page-120.ans
- out/screen-page-46.ans
- out/screen-stands-120.ans
- out/screen-stands-46.ans
- out/strace.txt
- out/unittest.log
- shots.py
- test_corrigenda.py