-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup
executable file
·121 lines (92 loc) · 2.74 KB
/
setup
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
#!/usr/bin/env bash
# script/setup: Set up system for the first time after cloning
set -euo pipefail
IFS=$'\n\t'
setup () {
cd "$(dirname "$0")/.."
bootstrap
msg_header "==> script/setup"
setup_secure_files
setup_rc
setup_shell
setup_iterm
setup_emacs
setup_asdf
setup_hosts
}
setup_secure_files () {
msg_info "==> Setting up secure files"
if [ -d "${dot_dir}/local" ]; then return; fi
ln -s "$(config_get secure_dir)" "${dot_dir}/local"
}
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_shell () {
msg_info "==> Setting up shell"
local shell_bin
shell_bin=$(config_get shell_bin)
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 () {
msg_info "==> Setting up hosts"
sudo hostile load "$(config_get secure_dir)/hosts"
}
if ! (return 0 2>/dev/null); then
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
dot_dir=$(dirname "$script_dir")
# shellcheck source=./bootstrap
source "${script_dir}/bootstrap"
setup "$@"
fi