From d3a4bf44df7801af48f2784a749b230a67dc264e Mon Sep 17 00:00:00 2001 From: Ben Sima Date: Mon, 14 Nov 2022 20:00:28 -0500 Subject: add cache script (extremely useful) --- cache | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 cache (limited to 'cache') diff --git a/cache b/cache new file mode 100755 index 0000000..60c09ae --- /dev/null +++ b/cache @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# cache commands for speed +# +set -eu +CACHE_DIR=~/.cache/command-cache +if [[ "$1" = "clear" ]]; then + rm -rf $CACHE_DIR +else + mkdir -p $CACHE_DIR + file="$CACHE_DIR/$(base64 <<< "$@")" + if [[ ! -e "$file" ]] + then + echo "making $file" >&2 + $@ > "$file" + fi + cat "$file" +fi -- cgit v1.2.3