|
@@ -1,12 +1,19 @@
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
+TEMPSPACE=$HOME/Workspace/temp
|
|
|
+
|
|
|
set -euo pipefail
|
|
|
|
|
|
-if [ "${1:-}" = "last" ]; then
|
|
|
- dir=$(ls "$HOME/Tempspace" | tail -n 1)
|
|
|
- cd "$HOME/Tempspace/$dir"
|
|
|
+cmd="${1:-}"
|
|
|
+
|
|
|
+if [ "$cmd" = "last" ]; then
|
|
|
+ dir=$(find "$TEMPSPACE" -type d -mindepth 1 -maxdepth 1 | sort | tail -n 1)
|
|
|
+ cd "$dir"
|
|
|
+elif [ "$cmd" = "prune" ]; then
|
|
|
+ echo "Deleting empty directories"
|
|
|
+ find "$TEMPSPACE" -type d -mindepth 1 -maxdepth 1 -empty -delete -print
|
|
|
else
|
|
|
- dir="$HOME/Tempspace/$(date +%s)"
|
|
|
+ dir="$TEMPSPACE/$(date +%s)"
|
|
|
mkdir "$dir"
|
|
|
cd "$dir"
|
|
|
fi
|