Skip to content

Instantly share code, notes, and snippets.

@ChrisPenner

ChrisPenner/cap.sh

Created Apr 5, 2020
Embed
What would you like to do?
Capture can replay command line output
#!/bin/bash
capdir=/tmp/cap
mkdir -p "$capdir"
record() {
tee "${capdir}/${1:-default}"
}
replay() {
cat "${capdir}/${1:-default}"
}
case $1 in
rec*)
shift; record "$1"
;;
rep*) shift; replay "$1"
;;
*) cat >&2 <<EOF
Usage:
Capture output:
cmd | cap record [capture name]
Output previous capture:
cap replay [capture name] | use output
EOF
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment