Created
August 4, 2023 01:54
-
-
Save mpslanker/964801d2f19f6918d4c4b97a129532a9 to your computer and use it in GitHub Desktop.
Clean up orphaned virtual environments from pipenv
This file contains 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
# Directory containing Pipenv virtual environments (modify if needed) | |
VENV_DIR="$HOME/.local/share/virtualenvs/" | |
for env in "$VENV_DIR"/*; do | |
if [ -d "$env" ]; then | |
project_path=$(cat "$env/.project") | |
if [ ! -d "$project_path" ]; then | |
echo "Removing orphaned environment for missing project $project_path" | |
# Remove the comment below to actually remove the folders | |
# rm -rf "$env" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment