add "box" script for managing temp directories

This commit is contained in:
Emile Clark-Boman 2025-08-08 20:13:51 +10:00
parent 0129fe2b97
commit d3a642fafb

44
scripts/box Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/env bash
USAGE="Usage: box [--enter]"
# ===== Configuration ===== #
DATA_DIR="$HOME/.data/box"
# ========================= #
function setup {
mkdir -p "$DATA_DIR" &>/dev/null
}
function box {
mktemp -d
# TODO: use a custom name instead
}
set -euo pipefail
ENTER=false
for arg in $@; do
case "$arg" in
-e|--enter)
ENTER=true
shift
;;
-h|--help)
echo "$USAGE"
;;
-*)
echo "[!] Unknown opt \"$arg\"" >&2
;;
*)
echo "[!] Unknown arg \"$arg\"" >&2
;;
esac
done
setup
BOX=$(box)
if [[ "$ENTER" == true ]]; then
cd "$BOX"
fi