vp (1221B) (RAW)
1 #!/bin/sh 2 3 # Install vim plugins listed in $PLIST. 4 # Uninstall vim plugins not listed in $PLIST. 5 # Format of $PLIST: {start,opt} <clone-url> 6 7 trap clean EXIT 8 9 clean() 10 { 11 rm -f "$TMP1" "$TMP2" 12 } 13 14 add() 15 { 16 printf 'Installing %s in %s... ' "${2##*/}" "$1" 17 git -C "${PPATH}/${1}" clone -q "$2" && printf 'done\n' 18 } 19 20 del() 21 { 22 printf 'Deleting %s from %s... ' "${2##*/}" "$1" 23 rm -rf "${PPATH:?}/${1}/${2##*/}" && printf 'done\n' 24 } 25 26 command -v "git" > /dev/null || { printf '%s: git: not found\n' "${0##*/}"; exit 1; } 27 28 TMP1=$(mktemp -t "${0##*/}".1.XXXXXXXXXX) || exit 1 29 TMP2=$(mktemp -t "${0##*/}".2.XXXXXXXXXX) || exit 1 30 31 PPATH="${HOME}/.vim/pack/plugins" 32 PLIST="${HOME}/.vim/pack/plugins/list" 33 mkdir -p "${PPATH}"/start \ 34 "${PPATH}"/opt 35 36 awk 'BEGIN { OFS = "\t" } 37 !/^[[:blank:]]*(start|opt)/ { next } 38 NF { print $1, $2 }' "$PLIST" | sort > "$TMP1" 39 40 find "$PPATH"/* -mindepth 1 -maxdepth 1 -type d | while IFS= read -r line; do 41 printf '%s\t%s\n' \ 42 "$(dirname "${line#*plugins/}")" \ 43 "$(git -C "$line" remote get-url origin)" 44 done | sort > "$TMP2" 45 46 comm -13 "$TMP1" "$TMP2" | while read -r line; do 47 del $line 48 done 49 50 comm -23 "$TMP1" "$TMP2" | while read -r line; do 51 add $line 52 done 53 54 "$EDITOR" -c "helptags ALL" -c q