#!/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" -type d -mindepth 1 -maxdepth 1 -empty -delete -print else dir="$TEMPSPACE/$(date +%s)" mkdir "$dir" cd "$dir" fi $SHELL