blob: 65c7fb45d1505a7dc316cf77fc5c1974e5e749f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/env bash
# package_dirs records directories of all installed packages. It is used
# to help clean unused packages.
package_dirs=()
update_package () {
name=$1
remote_url=$2
load_type=$3
package_dir="$HOME/.vim/pack/vendor/$load_type/$name"
package_dirs+=($package_dir)
if [ ! -d $package_dir ]; then
echo "$name : Installing ... "
mkdir -p $package_dir
git clone --depth 1 $remote_url $package_dir
else
cd $package_dir
echo "$name : Updating ... "
git pull && echo "$name : Done" || echo "$name : FAIL"
fi
}
clean () {
for load_type in 'opt' 'start'; do
for package_name in $(ls $HOME/.vim/pack/vendor/$load_type); do
package_dir=$HOME/.vim/pack/vendor/$load_type/$package_name
if [[ ! " ${package_dirs[*]} " =~ " ${package_dir} " ]]; then
read -r -p "rm -rf $package_dir? [y/N]: "
response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]]; then
rm -rf $package_dir
fi
fi
done
done
}
update_package "nnn.vim" "[email protected]:mcchrish/nnn.vim.git" "opt"
clean
|