-
Notifications
You must be signed in to change notification settings - Fork 0
/
scoop.sh
90 lines (72 loc) · 1.67 KB
/
scoop.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
set -eu
function LOG_impl() {
local -r loglevel=$1
local -r messages=${*:2}
local -r timestamp=$(date +'%Y/%m/%d %H:%M:%S.%3N')
echo "[${timestamp}] ${loglevel} ${messages}"
}
function LOGD() {
local -r messages=$*
local -r LEVEL='D'
LOG_impl ${LEVEL} "${messages}"
}
function LOGI() {
local -r messages=$*
local -r LEVEL='I'
LOG_impl ${LEVEL} "${messages}"
}
function LOGE() {
local -r messages=$*
local -r LEVEL='E'
LOG_impl ${LEVEL} "${messages}"
}
function add_bucket() {
local -r bucket_name=$1
local exists=0
set +e
scoop bucket list | grep "${bucket_name}" > /dev/null
exists=$?
set -e
if [ ${exists} -eq 0 ]; then
LOGD "Already added ${bucket_name}"
return
fi
LOGI "Add bucket ${bucket_name}"
scoop bucket add "${bucket_name}"
}
function install_package() {
local -r package_name=$1
local exists=0
set +e
scoop list | grep "${package_name}" > /dev/null
exists=$?
set -e
if [ ${exists} -eq 0 ]; then
LOGD "Already installed ${package_name}"
return
fi
LOGI "Install ${package_name}"
scoop install "${package_name}"
}
function main() {
add_bucket "extras"
mkdir -p ~/.config/git
echo '/.vscode' > ~/.config/git/ignore
git config --global core.autocrlf false
git config --global core.editor nano
git config --global pull.ff only
local packages=(\
"jq" \
"make" \
"peazip" \
"shellcheck" \
"vscode" \
"winmerge" \
"yq" \
)
for package in "${packages[@]}"; do
install_package "${package}"
done
}
main "$@"