brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: script -r records a terminal session with timing, and script -p plays it back

Terminal
~/tips/tip-terminal-script-r-replay

script -r demo.rec

Records a terminal session so you can replay it later at its original speed.

A plain log shows what was printed, not how it unfolded. The macOS script can store timing too and replay the session like a video.

Start a recording. Everything you do runs in a new shell until you type exit:

script -r demo.rec
# work as usual, then
exit

Play it back in the terminal, with the same pauses as when it was recorded:

script -p demo.rec

Add -d to skip the pauses and see it all at once. You can also record a single command, which is how I’d capture a flaky install step:

script -q -r install.rec ./install.sh
script -p -d install.rec

The file is a binary format, not a text log, so open it with script -p rather than cat.

This is the BSD version on the Mac. On Linux, util-linux script uses -T or --log-timing with scriptreplay instead, so the commands don’t carry over. And remember what a recording holds: everything you typed and saw, including passwords that were echoed and tokens printed on screen. Treat the file like a log with secrets in it.

Further reading: script man page (macOS)

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link