-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·94 lines (80 loc) · 2.8 KB
/
setup.sh
File metadata and controls
executable file
·94 lines (80 loc) · 2.8 KB
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
91
92
93
94
#!/bin/bash
# For setting up my mac
cd "$(dirname "$0")" || exit 1
# Things to be installed
brewPackages=()
brewCasks=()
codeExtensions=()
# `brew leaves > brew_leaves.txt`
[ -f brew_leaves.txt ] && mapfile -t brewPackages < brew_leaves.txt
# `brew list --casks > brew_casks.txt`
[ -f brew_casks.txt ] && mapfile -t brewCasks < brew_casks.txt
# `code --list-extensions > vscode_extensions.txt`
[ -f vscode_extensions.txt ] && mapfile -t codeExtensions < vscode_extensions.txt
# Tap any third-party taps used by the inventory files (e.g. cvc5/cvc5 for the
# cvc5 cask) before installs.
./scripts/setup-brew-taps.sh
# Install brew bottles
for i in "${brewPackages[@]}"; do
if brew ls --versions "$i" > /dev/null; then
echo "$i" was already installed
else
brew install "$i"
fi
done
brew upgrade
# Install brew casks, only available on mac
if [ "$(uname)" == "Darwin" ]; then
for i in "${brewCasks[@]}"; do
if brew ls --cask --versions "$i" > /dev/null; then
echo "$i" was already installed
else
brew install --cask "$i"
fi
done
fi
if command -v code >/dev/null 2>&1; then
mapfile -t currentExtensions < <(code --list-extensions)
for i in "${codeExtensions[@]}"; do
if printf '%s\n' "${currentExtensions[@]}" | grep -Fxq "$i"; then
echo "$i" is already installed for VScode
else
code --install-extension "$i"
fi
done
else
echo "VScode was not installed so we won't do extensions"
fi
if ! command -v cargo >/dev/null 2>&1; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
rustup toolchain install nightly
fi
# Install npm globals (`npm ls -g --depth=0 --parseable ... > npm_globals.txt`).
if command -v npm >/dev/null 2>&1 && [ -f npm_globals.txt ]; then
mapfile -t npmGlobals < npm_globals.txt
mapfile -t currentNpm < <(npm ls -g --depth=0 --parseable | tail -n +2 | awk -F/ '{print $NF}')
for i in "${npmGlobals[@]}"; do
[ -z "$i" ] && continue
if printf '%s\n' "${currentNpm[@]}" | grep -Fxq "$i"; then
echo "$i" is already installed for npm
else
npm install -g "$i"
fi
done
fi
# Install cargo binaries (`cargo install --list` filtered to crates.io only).
if command -v cargo >/dev/null 2>&1 && [ -f cargo_installs.txt ]; then
mapfile -t cargoBins < cargo_installs.txt
mapfile -t currentCargo < <(cargo install --list | grep -E '^[a-zA-Z0-9_-]+ v[0-9].*:$' | awk '{print $1}')
for i in "${cargoBins[@]}"; do
[ -z "$i" ] && continue
if printf '%s\n' "${currentCargo[@]}" | grep -Fxq "$i"; then
echo "$i" is already installed for cargo
else
cargo install "$i"
fi
done
fi
chmod +x link.sh
./link.sh