#/usr/bin/env bash
#
# Check vim plugins dir for unused plugins
# Note: does not perform deletion at this time, pipe output to bash.

set -e

pluginhome=$HOME/.vim/pack/git-plugins/opt
cd $pluginhome

find . -mindepth 1 -maxdepth 1 -type d -print0 | while read -d $'\0' pluginpath
do
  if ! grep -q "$pluginpath" $HOME/.vimrc ; then
    basename=$(basename $pluginpath)
    echo "rm -rf $pluginhome/$basename"
  fi
done