-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
executable file
·159 lines (137 loc) · 3.54 KB
/
install
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
#! /bin/bash
set -euo pipefail
# helpers
function log {
printf "\e[36m%s\e[0m\n" "${@}"
}
function run {
printf "\e[35;1m%s\e[0m\n" "- $(sed 's/_/ /g' <<<"$@") -"
"$@"
printf '\n\n'
}
function setx {
set -x
"$@"
{ set +x; } 2>/dev/null
}
# operations
function install_xcode {
if xcode-select -p; then
log "xcode looks ok"
return
fi
log "installing xcode"
setx xcode-select --install
read -p "press enter when completed..."
hash -r
}
function ssh_keys {
function check {
{ ssh [email protected] || :; } 2>&1 | grep "You've successfully authenticated"
}
if check; then
log "ssh keys look ok"
return
fi
log "install ssh keys"
open https://github.com/settings/keys
read -p "press enter when completed..."
check
}
function install_brew {
if which brew; then
log "brew looks ok"
return
fi
log "install homebrew"
open https://brew.sh/
read -p "press enter when completed..."
hash -r
}
function workstation_repo {
local workstation_repo="${HOME}/repos/workstation"
if [ -d "${workstation_repo}/.git" ]; then
log "workstation repo looks ok"
else
log "cloning workstation repo"
mkdir -vp "${HOME}/repos"
cd "${HOME}/repos"
setx git clone [email protected]:hypergig/workstation.git
fi
setx cd ${workstation_repo}
setx pwd
}
function setup_vars {
source config/.vars
hash -r
echo "brew prefix: ${HOMEBREW_PREFIX}"
}
function brew_bundle {
log "running brew bundle"
setx brew bundle --no-lock
hash -r
log "setting up startup services"
skhd --start-service
yabai --start-service
}
function dot_files {
local links=(
"config/.bash_profile ${HOME}/.bash_profile"
"config/.gitconfig ${HOME}/.gitconfig"
"config/.gitignore ${HOME}/.gitignore"
"config/.vars ${HOME}/.vars"
"config/alacritty.toml ${HOME}/.config/alacritty/alacritty.toml"
"config/init.vim ${HOME}/.config/nvim/init.vim"
"config/NeoSolarized.vim ${HOME}/.config/nvim/colors/NeoSolarized.vim"
"config/skhdrc ${HOME}/.config/skhd/skhdrc"
"config/yabairc ${HOME}/.config/yabai/yabairc"
"config/yabairc ${HOME}/.config/yabai/yabairc"
)
for link in "${links[@]}"; do
read _ dest <<<"${link}"
mkdir -pv "$(dirname "${dest}")"
ln -srvf ${link}
done
}
function setup_shell {
local bash_shell="${HOMEBREW_PREFIX}/bin/bash"
local shells='/etc/shells'
if grep "${bash_shell}" "${shells}"; then
log "bash shell is already listed in ${shells}"
else
log "adding bash to list of shells"
setx sudo sh -c "echo ${bash_shell} >> ${shells}"
fi
if [ "${SHELL}" == "${bash_shell}" ]; then
log "bash shell is already set as default shell"
else
log "setting bash as default shell"
setx chsh -s "${bash_shell}"
fi
}
function set_desktop_background {
setx osascript -e "tell application \"Finder\" to set desktop picture to POSIX file \"${_workstation_dir}/config/backgrounds/solarizedBig.png\""
}
function install_defaults {
setx cd config/defaults
for scope in *; do
setx defaults import "${scope}" "${scope}"
done
setx cd -
}
# install
operations=(
install_xcode
ssh_keys
install_brew
workstation_repo
setup_vars
brew_bundle
dot_files
setup_shell
set_desktop_background
install_defaults
)
for operation in "${operations[@]}"; do
run "${operation}"
done