Last active
August 29, 2015 14:07
-
-
Save apuignav/f6f145c27f24ee302558 to your computer and use it in GitHub Desktop.
Create a temp directory and open a shell in it. When finished, delete the temp directory.
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 zsh --login | |
| # Create temp dir | |
| tmp=${1-$TMPDIR} | |
| tmp=$tmp/tmp.$RANDOM.$RANDOM.$RANDOM.$$ | |
| (umask 077 && mkdir $tmp) || { | |
| echo "Could not create temporary directory! Exiting." 1>&2 | |
| exit 1 | |
| } | |
| # Go to it and start a new shell | |
| cd $tmp | |
| /usr/bin/env TMPSHELL=1 zsh | |
| # Delete temp files | |
| rm -rf $tmp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment