Created
April 5, 2026 20:58
-
-
Save intellectronica/92ea51bc887b002eefdf20ed94135706 to your computer and use it in GitHub Desktop.
Temp Dirs @ Home
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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