add "box" script for managing temp directories
This commit is contained in:
parent
0129fe2b97
commit
d3a642fafb
1 changed files with 44 additions and 0 deletions
44
scripts/box
Executable file
44
scripts/box
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue