-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·107 lines (90 loc) · 2.96 KB
/
install
File metadata and controls
executable file
·107 lines (90 loc) · 2.96 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
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/sh
#
# Install the dotfiles, software and configurations.
DOTFILES="${HOME}/.config/dotfiles"
assert_zsh_shell() {
if [ "$(basename "${SHELL}")" != "zsh" ]; then
echo "ERROR: these dotfiles require the Zsh shell and your shell is ${SHELL}."
echo ' Please change your shell to Zsh, and make sure SHELL is set.'
echo ' To change the shell use e.g. with "chsh -s /bin/zsh".'
echo ' After changing the shell to Zsh, re-run this script.'
exit 1
fi
}
link_files() {
local source="${DOTFILES}/${1}"
local dest="${2}"
if [ -e "${dest}" ] && [ ! -h "${dest}" ]; then
echo " WARN: symlink failed, \"${dest}\" exists and is not a symlink"
elif [ -h "${dest}" ] && [ "$(readlink "${dest}")" != "${source}" ]; then
echo " WARN: symlink failed, \"${dest}\" is linked to another path"
elif [ ! -e "${dest}" ]; then
echo " [sync] symlink \"${source}\" to \"${dest}\""
ln -s "${source}" "${dest}"
fi
}
sync_dotfiles() {
echo " INFO: syncing dotfiles"
mkdir -p "${DOTFILES}"
rsync \
--archive \
--delete \
--exclude ".DS_Store" \
--exclude ".git/" \
--exclude ".github/" \
--exclude "node_modules/" \
--exclude "custom/" \
--human-readable \
--no-perms \
--itemize-changes \
. "${DOTFILES}" \
| sed -u 's/^/ [sync] /'
echo " INFO: syncing custom files (custom/)"
rsync \
--archive \
--exclude ".DS_Store" \
--exclude ".gitignore" \
--human-readable \
--no-perms \
--itemize-changes \
./custom/ "${DOTFILES}/custom/" \
| sed -u 's/^/ [sync] /'
link_files ".editorconfig" "${HOME}/.editorconfig"
link_files ".gitignore" "${HOME}/.gitignore"
link_files "git/.gitconfig" "${HOME}/.gitconfig"
link_files "zsh/.zshrc" "${HOME}/.zshrc"
link_files "ghostty/" "${HOME}/.config/ghostty"
mkdir -p "${HOME}/.config/mise"
link_files "mise/config.toml" "${HOME}/.config/mise/config.toml"
link_files "nvim/" "${HOME}/.config/nvim"
link_files "zsh/starship.toml" "${HOME}/.config/starship.toml"
if is_macos; then
link_files "vscode/settings.json" "${HOME}/Library/Application Support/Code/User/settings.json"
link_files "vscode/keybindings.json" "${HOME}/Library/Application Support/Code/User/keybindings.json"
else
mkdir -p "${HOME}/.config/Code/User"
link_files "vscode/settings.json" "${HOME}/.config/Code/User/settings.json"
link_files "vscode/keybindings.json" "${HOME}/.config/Code/User/keybindings.json"
fi
}
assert_zsh_shell
. ./macos/is-macos
sync_dotfiles
if [ -n "${DOTFILES_SYNC_ONLY}" ]; then
exit 0
fi
. "${DOTFILES}/homebrew/install"
. "${DOTFILES}/mise/install"
if is_macos; then
echo " INFO: configuring macOS"
for file in "${DOTFILES}/macos/"*; do
. "${file}"
done
echo " WARN: a restart of macOS may be required to apply all changes"
fi
# Custom installation.
if [ -f "${DOTFILES}/custom/install" ]; then
echo " INFO: calling custom installation script"
. "${DOTFILES}/custom/install"
fi
exit 0