Skip to content

Instantly share code, notes, and snippets.

@xamfy
Forked from Sidd-Dino/delete_on_exit_temp_folder.sh
Created September 22, 2020 17:11
Show Gist options
  • Select an option

  • Save xamfy/e1f2711f9e482cdce923790e02e1d392 to your computer and use it in GitHub Desktop.

Select an option

Save xamfy/e1f2711f9e482cdce923790e02e1d392 to your computer and use it in GitHub Desktop.
folder which deletes itself when you leave it
#!/usr/bin/env bash
#This script was made on a request from one of my human
# friends. He needed a folder that would delete itself when
# leaves it.
#
# Press Ctrl+d to leave the folder and let it delete itself
#time used to creaate uniques folders
time=$(printf "%(%l%M%S)T\\n" "-1")
mkdir temp_folder_"$time"
__old_pwd__="$PWD"
cd temp_folder_"$time" && "$SHELL"
cd "$__old_pwd__" || exit
rm -rf "temp_folder_$time"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment