-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·89 lines (79 loc) · 2.1 KB
/
bootstrap.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
#!/usr/bin/env bash
# Bootstraps my dotfiles
# Inspired by https://github.com/mathiasbynens/dotfiles
# Show help menu
usage ()
{
1>&2 printf -- "Usage: %s [-hfx]\n" "$0"
1>&2 printf -- "\t-h: Show help menu\n"
1>&2 printf -- "\t-f: Force install\n"
1>&2 printf -- "\t-x: Install codium extensions\n"
}
# Default option values
unset FORCE CODIUM_EXTENSIONS
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
pwd
# Parse command-line options
while getopts "hfx" opt ; do
case "${opt}" in
f)
FORCE=1
;;
x)
CODIUM_EXTENSIONS=1
;;
h)
usage
exit 0
;;
*)
usage
exit 1
;;
esac
done
# Helper function to sync dotfiles
rsync_dots ()
{
rsync --exclude "**/.git/" \
--exclude "**/.gitmodules" \
--exclude "**/.git" \
--exclude "**/.gitignore" \
--exclude "**/.gitlab-ci.yml" \
--exclude "**/.pre-commit-config.yaml" \
--exclude "**/.vscode/" \
--exclude "**/README.md" \
--exclude "**/LICENSE" \
--exclude "**/.mypy_cache" \
--exclude "**/.ruff_cache" \
--exclude "bootstrap.sh" \
--exclude ".config/VSCodium/extensions.txt" \
-avgh --no-perms . "${HOME}"
if [[ "${CODIUM_EXTENSIONS}" ]] ; then
if command -v codium > /dev/null ; then
echo -e "\nInstalling VSCodium extensions"
while IFS= read -r line ; do
echo "${line}"
codium --install-extension "${line}" > /dev/null
done < <(grep -v '^ *#' < .config/VSCodium/extensions.txt)
else
echo -e "\nVSCodium is not installed"
fi
fi
source "${HOME}/.bash_profile"
}
# Update repository
git pull --recurse-submodules
if [[ "${FORCE}" ]] ; then
rsync_dots
else
read -r -p "This may overwrite the existing configuration. Are you sure? [y/N] " -n 1
echo
if [[ "${REPLY}" =~ ^[Yy]$ ]] ; then
rsync_dots
else
exit 1
fi
fi
unset CODIUM_EXTENSIONS FORCE rsync_dots
# vim: ft=bash