···11+#!/usr/bin/env bash
22+33+# Loop over each line of the .tool-versions file
44+while read -r line; do
55+ IFS=' ' read -r -a tool_and_versions <<< "$line"
66+ # Split out the tool name and versions
77+ tool_name="${tool_and_versions[0]}"
88+ global_versions=("${tool_and_versions[@]:1}")
99+1010+ # Loop over each version of the tool name
1111+ for version in $(asdf list $tool_name); do
1212+ # When version not in `global_versions` array from .tool-versions file
1313+ if [[ ! " ${global_versions[@]} " =~ " ${version} " ]]; then
1414+ asdf uninstall $tool_name $version
1515+ fi
1616+ done
1717+done < ~/.tool-versions