summaryrefslogtreecommitdiff
path: root/cache
blob: 60c09ae1e9f3a949b7c6859542b313145a39c101 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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