summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcreate-temp19
1 files changed, 19 insertions, 0 deletions
diff --git a/create-temp b/create-temp
new file mode 100755
index 0000000..fe9da4c
--- /dev/null
+++ b/create-temp
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -e
+
+TODAY="$(date '+%F')"
+BASE="$HOME/.temp"
+TARGET="$HOME/tmp"
+
+
+rmdir "$BASE/"* 2> /dev/null || true
+
+[ -d "$BASE/$TODAY" ] || mkdir "$BASE/$TODAY"
+if ! [ -L "$TARGET" ] && [ -e "$TARGET" ]; then
+ echo "$0: '$TARGET' already exists and is not a symlink." >&2
+ exit 1;
+fi
+
+rm -f "$TARGET"
+ln -s "$BASE/$TODAY" "$TARGET"