Skip to content

Instantly share code, notes, and snippets.

@mpslanker
Created August 4, 2023 01:54
Show Gist options
  • Save mpslanker/964801d2f19f6918d4c4b97a129532a9 to your computer and use it in GitHub Desktop.
Save mpslanker/964801d2f19f6918d4c4b97a129532a9 to your computer and use it in GitHub Desktop.
Clean up orphaned virtual environments from pipenv
# 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