-
Notifications
You must be signed in to change notification settings - Fork 0
/
computer_bootstrap
executable file
·96 lines (87 loc) · 3.24 KB
/
computer_bootstrap
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
95
96
#!/usr/bin/env bash
set -u
shared_user_dirs=("Repos" "Documents" "Downloads" "Shared" "Music" "data")
# create default user directories
case "$ON_OS" in
windows*)
# on windows (WSL), link these to /mnt/c/
# check the WHOME variable set in my .profile
for d_name in "${shared_user_dirs[@]}"; do
target="${WHOME}/${d_name}"
if [[ ! -d "${HOME}/${d_name}" ]]; then
[[ ! -d "${target}" ]] && mkdir -p "${target}"
ln -s "${target}" "${HOME}/${d_name}"
fi
done
;;
*)
# otherwise
default_user_dirs=("${shared_user_dirs[@]}")
default_user_dirs+=("Pictures/Screenshots" ".local/bin" ".cache" ".credentials" ".local/share/Public" ".local/share/Templates")
for d_name in "${default_user_dirs[@]}"; do
if [[ ! -d "${HOME}/${d_name}" ]]; then
mkdir -pv "${HOME}/${d_name}"
fi
done
;;
esac
set +u
echo "Installing computer python packages..."
python3 -m pip install --user --break-system-packages -q -r "${PACKAGE_DIR}/computer_python.txt"
install_python_personal "plus1" "https://github.com/purarue/plus1"
install_python_personal "pythonanywhere_3_months" "https://github.com/purarue/pythonanywhere-3-months"
install_python_personal "calcurse_load" "https://github.com/purarue/calcurse-load"
havecmd cargo || exit $?
echo "Installing global cargo packages..."
CARGO_PACKAGE_LIST="${PACKAGE_DIR}/cargo_packages.txt"
CARGO_INSTALLED_PACKAGES="$(cargo install --list | sed -E -e '/^\s+/d; s|\s.*||')"
while read -r cargopkg; do
if ! grep -qx "${cargopkg}" <<<"${CARGO_INSTALLED_PACKAGES}"; then
printf "Installing %s\n" "${cargopkg}"
cargo install "${cargopkg}"
fi
done < <(spkglist "${CARGO_PACKAGE_LIST}")
DART_PACKAGE_LIST="${PACKAGE_DIR}/dart_packages.txt"
havecmd dart && {
echo "Installing global dart packages..."
DART_INSTALLED_PACKAGES="$(dart pub global list | cut -d" " -f1)"
while read -r dartpkg; do
if ! grep -qx "${dartpkg}" <<<"${DART_INSTALLED_PACKAGES}"; then
printf "Installing %s\n" "${dartpkg}"
dart pub global activate "${dartpkg}"
fi
done < <(spkglist "${DART_PACKAGE_LIST}")
}
MIX_PACKAGE_LIST="${PACKAGE_DIR}/mix_archive_packages.txt"
havecmd mix && {
echo "Installing global phoenix mix archives..."
MIX_ARCHIVE_LIST="$(mix archive | tac | sed -e '1d; s/^* //; s/-.*//')"
while read -r mix_pkg; do
if ! grep -qx "${mix_pkg}" <<<"${MIX_ARCHIVE_LIST}"; then
mix archive.install --force hex "${mix_pkg}"
fi
done < <(spkglist "${MIX_PACKAGE_LIST}")
}
GH_PACKAGE_LIST="${PACKAGE_DIR}/gh_extension_packages.txt"
havecmd gh && {
GH_INSTALLED_PACKAGES="$(gh extension list | awk '{print $3}')"
while read -r gh_pkg; do
if ! grep -qx "${gh_pkg}" <<<"$GH_INSTALLED_PACKAGES"; then
gh extension install "https://github.com/${gh_pkg}"
fi
done < <(spkglist "${GH_PACKAGE_LIST}")
}
declare -rx OCAML_PACKAGE_LIST="${PACKAGE_DIR}/ocaml_packages.txt"
havecmd opam && {
eval "$(opam env)"
# install opam packages
OPAM_INSTALLED="$(opam list -s --columns=name)"
while read -r opam_pkg; do
if ! grep -xq "${opam_pkg}" <<<"${OPAM_INSTALLED}"; then
printf "Installing %s\n" "$opam_pkg"
opam install -y "${opam_pkg}"
fi
done < <(spkglist "${OCAML_PACKAGE_LIST}")
}
clone-repos ~/.config/clone-repos/computer-clone-repos.yaml
havecmd mapscii-at || yarn global add --prefix "${HOME}/.local" git+https://github.com/purarue/mapscii-at