Commit d22fb4b908bccf598029fe369331f3fbbf9f7cad

Authored by Shrikant Sharat
1 parent d1b3870047

bundle-cleanup command to remove unused bundles.

Showing 1 changed file with 30 additions and 0 deletions Side-by-side Diff

... ... @@ -107,6 +107,36 @@ bundle-install! () {
107 107 bundle-install --update
108 108 }
109 109  
  110 +bundle-cleanup () {
  111 +
  112 + # Find directores in ANTIGEN_BUNDLE_DIR, that are not in the bundles record.
  113 + local unidentified_bundles="$(comm -13 \
  114 + <(echo-non-empty "$bundles" | awk '{print $1}' | sort) \
  115 + <(ls -1 "$ANTIGEN_BUNDLE_DIR"))"
  116 +
  117 + if [[ -z $unidentified_bundles ]]; then
  118 + echo "You don't have any unidentified bundles."
  119 + return 0
  120 + fi
  121 +
  122 + echo The following bundles are not recorded:
  123 + echo "$unidentified_bundles" | sed 's/^/ /'
  124 +
  125 + echo -n '\nDelete them all? [y/N] '
  126 + if read -q; then
  127 + echo
  128 + echo
  129 + echo "$unidentified_bundles" | while read name; do
  130 + echo -n Deleting $name...
  131 + rm -rf "$ANTIGEN_BUNDLE_DIR/$name"
  132 + echo ' done.'
  133 + done
  134 + else
  135 + echo
  136 + echo Nothing deleted.
  137 + fi
  138 +}
  139 +
110 140 bundle-load () {
111 141 if [[ $1 == --init ]]; then
112 142 do_init=true