-
Notifications
You must be signed in to change notification settings - Fork 5
/
vscode-sync.sh
executable file
·45 lines (38 loc) · 1.05 KB
/
vscode-sync.sh
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
#!/usr/bin/env bash
vscodeInstance="code"
if [ "$1" == "--insiders" ]; then
vscodeInstance="code-insiders"
shift
fi
fullsync=false
if [ "$1" == "--full" ]; then
fullsync=true
fi
# test code is installed
command -v $vscodeInstance >/dev/null 2>&1 || {
echo >&2 "This script requires $vscodeInstance but it's not installed. Aborting."
exit 1;
}
syncText=$($vscodeInstance --list-extensions | diff vscode-plugins.txt -)
# < install
install=$(echo "$syncText" | grep "^<")
# > uninstall
uninstall=$(echo "$syncText" | grep "^>")
if [ "$fullsync" = true ]; then
# readarray -t extensions <<< "$uninstall"
IFS=$'\n' read -rd '' -a extensions <<< "$uninstall"
for extension in "${extensions[@]}"; do
ext="${extension#"> "}"
if [ ! -z "$ext" ]; then
$vscodeInstance --uninstall-extension $ext
fi
done
fi
# readarray -t extensions <<< "$install"
IFS=$'\n' read -rd '' -a extensions <<< "$install"
for extension in "${extensions[@]}"; do
ext="${extension#"< "}"
if [ ! -z "$ext" ]; then
$vscodeInstance --install-extension $ext
fi
done