Forked from Sidd-Dino/delete_on_exit_temp_folder.sh
Created
September 22, 2020 17:11
-
-
Save xamfy/e1f2711f9e482cdce923790e02e1d392 to your computer and use it in GitHub Desktop.
folder which deletes itself when you leave it
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
| #!/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