123456789101112131415161718192021 |
- #!/usr/bin/env bash
- TEMPSPACE=$HOME/Workspace/temp
- set -euo pipefail
- 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" -mindepth 1 -maxdepth 1 -type d -empty -delete -print
- exit
- else
- dir="$TEMPSPACE/$(date +%s)"
- mkdir "$dir"
- cd "$dir"
- fi
- $SHELL
|