-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_extensions
executable file
·50 lines (43 loc) · 1.02 KB
/
install_extensions
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/bash
cd "$(dirname "$0")" || return
declare -i dry_run=0
declare extensions_to_install
while (($#)); do
case $1 in
--dry-run | -n)
dry_run=1
readonly dry_run
shift
;;
--insiders | -i)
code='code-insiders'
readonly insiders=1
shift
;;
--* | -*)
echo "error: unknown option '$1'" >&2
exit 1
;;
*)
shift
;;
esac
done
if [[ $insiders == 1 ]]; then
extensions_to_install="$(code-insiders --list-extensions | diff -u - extensions | tail -n +4 | grep '^\+' | sed 's/\+//')"
else
extensions_to_install="$(code --list-extensions | diff -u - extensions | tail -n +4 | grep '^\+' | sed 's/\+//')"
fi
readonly extensions_to_install
if [[ -z $extensions_to_install ]]; then
echo 'Nothing to install'
fi
if [[ $dry_run == 1 ]]; then
echo "$extensions_to_install" | xargs -I {} echo 'Would install {}'
else
if [[ $insiders == 1 ]]; then
echo "$extensions_to_install" | xargs -I {} code-insiders --install-extension {}
else
echo "$extensions_to_install" | xargs -I {} code --install-extension {}
fi
fi