Skip to content

Instantly share code, notes, and snippets.

@nv1t
Created December 17, 2019 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nv1t/37cbaa3ec88dca123fa9801aff5a3b11 to your computer and use it in GitHub Desktop.
Save nv1t/37cbaa3ec88dca123fa9801aff5a3b11 to your computer and use it in GitHub Desktop.
I work with pipenv a lot. Sometimes a delete or move a directory and forget to delete the virtualenv and so it lingers around in .local. this is a small wrapper to delete all the orphaned virtualenv directories :)
function rmvirtualenv() {
for i in ~/.local/share/virtualenvs/*/.project; do
venv=$(dirname "${i}")
directory=$(cat "${i}")
echo "${venv}"
if [ -d "${directory}" ] && [ -f "${directory}/Pipfile" ]; then
echo -n "[+] "
else
echo -n "[-] "
rm -r "${venv}"
fi
echo "${directory}"
echo
done;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment