Repository navigation
Expand file tree
/
Copy pathsetup
More file actions
executable file
·167 lines (129 loc) · 3.88 KB
/
Copy pathsetup
File metadata and controls
executable file
·167 lines (129 loc) · 3.88 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/usr/bin/env bash
# script/setup: Set up system for the first time after cloning
set -euo pipefail
IFS=$'\n\t'
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
DOT_DIR=$(dirname "$SCRIPT_DIR")
# shellcheck source=./bootstrap
source "${SCRIPT_DIR}/bootstrap"
# shellcheck source=./lib/git-signing.sh
source "${SCRIPT_DIR}/lib/git-signing.sh"
setup () {
cd "$DOT_DIR"
bootstrap
msg_header "==> script/setup"
setup_secure_files
setup_rc
setup_git_signing_step
setup_shell
setup_iterm
setup_emacs
setup_asdf
setup_hosts
}
setup_secure_files () {
msg_info "==> Setting up secure files"
if [ -L "${DOT_DIR}/local" ] && [ ! -e "${DOT_DIR}/local" ]; then
msg_warn "==> Removing dangling local symlink"
rm "${DOT_DIR}/local"
elif [ -d "${DOT_DIR}/local" ]; then
return
fi
local secure_dir
secure_dir=$(config_get secure_dir "")
if [ -n "$secure_dir" ] && [ -d "$secure_dir" ]; then
ln -s "$secure_dir" "${DOT_DIR}/local"
else
mkdir -p "${DOT_DIR}/local"
msg_info "==> Created local directory for machine-specific files"
fi
}
setup_rc () {
msg_info "==> Setting up RC files"
# Set this repo as the source directory.
echo "DOTFILES_DIRS=\"${DOT_DIR}\"" >> ./rcrc
env RCRC="${DOT_DIR}/rcrc" rcup
}
setup_git_signing_step () {
local skip
skip=$(config_get skip_setup_git_signing 0)
if [ "${skip}" == "1" ]; then return; fi
setup_git_signing
config_set skip_setup_git_signing 1
}
setup_shell () {
msg_info "==> Setting up shell"
local shell_bin
shell_bin=$(config_get shell_bin "")
if [ -z "$shell_bin" ]; then
msg_warn "==> shell_bin not configured; skipping shell setup"
return
fi
local shells="/etc/shells"
if [ "${SHELL}" = "${shell_bin}" ]; then
msg_info "default shell configured (${shell_bin})"
return
fi
if [ ! -f "${shell_bin}" ]; then
msg_error "${shell_bin} does not exist!"
exit 1
fi
if ! file_contains "${shells}" "${shell_bin}"; then
echo "${shell_bin}" | sudo tee -a "${shells}" > /dev/null
fi
sudo chsh -s "${shell_bin}"
msg_info "default shell configured (${shell_bin}) ...restart required"
}
setup_iterm () {
msg_info "==> Setting up iTerm2 preferences"
local dir
local plist
plist="com.googlecode.iterm2.plist"
# Specify the preferences directory
dir="$(pwd)/iTerm2"
defaults write "${plist}" PrefsCustomFolder -string "${dir}"
# Tell iTerm2 to use the custom preferences in the directory
defaults write "${plist}" LoadPrefsFromCustomFolder -bool true
}
setup_emacs () {
msg_info "==> Setting up Emacs"
local work_dir
msg_info "==> Building elixir language server"
work_dir=$(pwd)
ghq get elixir-lsp/elixir-ls
cd "$(ghq list -p elixir-lsp/elixir-ls)"
mix deps.get
mix compile
mix elixir_ls.release -o release
cd "${work_dir}"
msg_info "==> Setting up emacs variants"
ghq get plexus/chemacs
"$(ghq list -p plexus/chemacs)"/install.sh
ghq get hlissner/doom-emacs
"$(ghq list -p hlissner/doom-emacs)"/bin/doom sync
"$(ghq list -p hlissner/doom-emacs)"/bin/doom doctor
ghq get syl20bnr/spacemacs
}
setup_asdf () {
msg_info "==> Setting up global tools"
less asdf-plugins | xargs -n 1 asdf plugin add
asdf install
}
setup_hosts () {
local secure_dir
secure_dir=$(config_get secure_dir "")
if [ -z "$secure_dir" ]; then
msg_warn "==> secure_dir not configured; skipping hosts setup"
return
fi
local hosts_file="$secure_dir/hosts"
if [ ! -f "$hosts_file" ]; then
msg_warn "==> Hosts file not found at $hosts_file; skipping"
return
fi
msg_info "==> Setting up hosts"
sudo hostile load "$hosts_file"
}
if ! (return 0 2>/dev/null); then
setup "$@"
fi