Skip to content

Instantly share code, notes, and snippets.

@intellectronica
Created April 5, 2026 20:58
Show Gist options
  • Select an option

  • Save intellectronica/92ea51bc887b002eefdf20ed94135706 to your computer and use it in GitHub Desktop.

Select an option

Save intellectronica/92ea51bc887b002eefdf20ed94135706 to your computer and use it in GitHub Desktop.
Temp Dirs @ Home
tmp() {
mkdir -p ~/.tmp
# Cleanup directories older than 23 days
find ~/.tmp -mindepth 1 -depth -Btime +23d -delete 2>/dev/null
local timestamp=$(date +%Y-%m-%d-%H-%M-%S)
local dir
if [[ -n "$1" ]]; then
# If argument provided, use it as the suffix
dir="$HOME/.tmp/tmp-$timestamp-$1"
mkdir -p "$dir"
else
# No argument, generate random suffix (5 chars like XXXXX)
dir=$(mktemp -d "$HOME/.tmp/tmp-$timestamp-XXXXX")
fi
cd "$dir"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment