No. 0543 min read
huh. What is this string, exactly?
A timestamp, a cron line, an exit code, an invisible Unicode character.
No. 0531 min read
A shell that can undo the last thing you did. No snapshotting filesystem, no daemon, no root, just python3 and a journal. 410 lines of Python and 54 of bash.
I gave myself a dumb challenge on a slow night: make a shell that can undo the last thing you did, with no snapshotting filesystem[1]Ref. 1Snapshot (computer storage) en.wikipedia.org, no daemon, no root, and nothing installed but python3. You type mv, you type undo, the file goes back. That was the whole spec.
It came out to 410 lines of Python and 54 lines of bash, and you source it into your shell. It's on GitHub[2]Ref. 2undo on GitHub github.com. There is no PyPI package, because the thing is a shell function and pip can't reach into your .bashrc for you.
Before mv, cp, rm, chmod, chown, mkdir, rmdir or ln runs, a wrapper computes the inverse, writes it to a journal under ~/.undo, and then runs the real command. rm[3]Ref. 3rm(1) man7.org is the special one: nothing gets destroyed. The file moves into a trash directory[4]Ref. 4Trash (computing) en.wikipedia.org and the journal remembers where it lived. Seven days later it's purged for real. undo -n shows you what would happen, undo -y does it, and undo -l lists the last ten so you can pick one.
The price: every mv now costs me 85 milliseconds instead of one, because two Python interpreters start up so I can feel safe. I measured it. I'm fine with it.
Things it will NOT save you from, and I wrote every one of them down in the README because I'd rather annoy you now than surprise you later: editor saves, redirects, anything under sudo, anything run from a script, and \rm, which bypasses an alias[5]Ref. 5Alias (command) en.wikipedia.org and does nothing at all to a shell function. If you want the real rm, type command rm. The README says best-effort recovery, in bold, and it is not a backup. Keep making backups, nimrod.
I have been typing rm for thirty years and it has never once asked me if I was fucking sure. Now I don't have to be.
No. 0543 min read
A timestamp, a cron line, an exit code, an invisible Unicode character.
No. 0441 min read
Corkscrew fits in 291 lines, folks.
No. 0431 min read
Corkscrew reported success without establishing a tunnel.
No. 0371 min read
Unix rename can publish a finished file or claim a queue item.