summaryrefslogtreecommitdiff
path: root/cache
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2022-11-14 20:00:28 -0500
committerBen Sima <ben@bsima.me>2022-11-14 20:00:28 -0500
commitd3a4bf44df7801af48f2784a749b230a67dc264e (patch)
treea73d9a5bf0d2e70a65dcca2278d24587538dda83 /cache
parent3b0d2b7f1693594f6831fa9048ed565c5c77aac0 (diff)
add cache script (extremely useful)
Diffstat (limited to 'cache')
-rwxr-xr-xcache18
1 files changed, 18 insertions, 0 deletions
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