Skip to content

Instantly share code, notes, and snippets.

@liamnewmarch
Created April 27, 2020 17:18
Show Gist options
  • Save liamnewmarch/90a6c1548a897c2faf627eda847398b9 to your computer and use it in GitHub Desktop.
Save liamnewmarch/90a6c1548a897c2faf627eda847398b9 to your computer and use it in GitHub Desktop.
Small utility to start a shell in a temporary directory and delete it afterwards
#!/usr/bin/env bash
BLUE='\033[1;34m'
RESET='\033[0m'
WHITE='\033[1;37m'
echo -e "Creating temp dir..."
tempdir=$(mktemp -d)
pushd $tempdir &>/dev/null
echo -e "${BLUE}!${WHITE} Starting a new shell. Type ${BLUE}exit${WHITE} to return.${RESET}"
$SHELL
echo -e "Removing temp dir..."
popd &>/dev/null
rm -rf $tempdir
echo -e "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment