-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-vim-plugins
executable file
·50 lines (35 loc) · 1.25 KB
/
update-vim-plugins
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
43
44
45
46
47
48
49
50
#!/bin/sh
if [ ! -d "$HOME/.vim-plugins" ]; then
echo "error: '$HOME/.vim-plugins' is not a directory" >&2
exit 1
fi
cd "$HOME/.vim-plugins"
mkdir -p "$HOME/.vim/autoload"
mkdir -p "$HOME/.vim/bundle"
cp vim-pathogen/autoload/pathogen.vim "$HOME/.vim/autoload"
nprocs="$(lscpu | awk '$1 == "CPU(s):" {print $2}')"
nplugins="$(echo * | wc -w)"
for plugin in *; do
(
cd "$HOME/.vim-plugins/$plugin" 2>/dev/null || exit
sleep $(($RANDOM % ($nplugins / (($nprocs / 2) - 1) + 1))) || exit
git wipe >/dev/null
git submodule update --init --recursive >/dev/null 2>&1
git update-all >/dev/null 2>&1
git checkout --quiet master
[ "$plugin" = "vimproc.vim" ] && make
if [ -z "$(find "$HOME/.vim/bundle" -maxdepth 1 -type d -name \
"$plugin")" ]; then
mkdir "$HOME/.vim/bundle/$plugin"
else
if [ -z "$(find "$HOME/.vim/bundle/$plugin" -maxdepth 1 -type d -name \
"plugin")" ]; then
exit
fi
fi
# Note: DO NOT first remove what is in there; just copy over and replace.
# This way any extra files manually added won't be overwritten.
cp -r * "$HOME/.vim/bundle/$plugin"
) &
done
wait