-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·252 lines (212 loc) · 6.79 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/bin/bash -e
# TODO
# Notes:
# - add in ./dev folder with user.clj to start (cljs) from inside a repl
# - add in figwheel fns to user.clj
# - include .gitignore
# - probably git init
# - ensure there is a resources/public/css
echo "Copying text files to useful locations from $PWD.."
cd $(dirname $BASH_SOURCE)
BASE=$(pwd)
OS="Linux"
join_by() { local IFS="$1"; shift; echo "$*"; }
detect_os() {
desc=$(uname -a)
if [[ $desc == *"microsoft-standard-WSL2"* ]]; then
OS="Windows"
elif [[ $desc = *"Darwin"* ]]; then
OS="Mac"
fi
}
detect_os
install_config_files() {
echo '. ~/.bashrc' > ~/.bash_profile
for rc in .*rc .tmux.conf; do
cp -v $BASE/$rc $HOME/$rc
done
mkdir -p $HOME/.vim/colors
cp -v $BASE/rollout.vim $HOME/.vim/colors/rollout.vim
mkdir -p $HOME/.emacs.d/
cp -v $BASE/init.el $HOME/.emacs.d/
cp -v $BASE/rollout-theme.el $HOME/.emacs.d/
}
configure_git() {
echo 'Configuring git..'
git config --global --replace-all core.editor 'vim'
git config --global --replace-all core.autocrlf false
git config --global --replace-all alias.aa 'add --all'
git config --global --replace-all alias.br 'branch --sort=committerdate'
git config --global --replace-all alias.st 'status'
git config --global --replace-all alias.count 'shortlog -sn'
git config --global --replace-all alias.ff 'pull --ff-only'
git config --global --replace-all alias.co 'checkout'
git config --global --replace-all alias.ci 'commit --verbose'
git config --global --replace-all alias.di 'diff'
git config --global --replace-all alias.dc 'diff --cached'
git config --global --replace-all alias.dd 'diff --stat origin/develop HEAD'
git config --global --replace-all alias.dn 'diff --name-status'
git config --global --replace-all alias.list 'config --global --list'
git config --global --replace-all alias.amend 'commit --amend'
git config --global --replace-all alias.ffa 'fetch --all && git rebase origin/master'
git config --global --replace-all alias.push-new 'push -u origin HEAD'
git config --global --replace-all alias.ra "log --abbrev-commit --pretty=format:'%<(7)%C(yellow)%h %Cgreen%<(15)%cr%C(bold cyan)%<(17)<%an>%C(red)%d %Creset %s'"
}
is_0() {
if [ "$1" = "0" ]; then
echo 'true'
return
fi
echo 'false'
}
exists() {
echo -n "Is $1 installed? "
[ $(command -v "$1") ] && echo 'true' || echo 'false'
}
if command -v selecta &> /dev/null; then
echo 'selecta is already installed'
else
echo 'selecta could not be found, installing to ~/.local/bin/selecta'
mkdir -p ~/.local/bin
curl https://raw.githubusercontent.com/garybernhardt/selecta/master/selecta -o ~/.local/bin/selecta
chmod +x ~/.local/bin/selecta
fi
compile_vim() {
# not complete.. just jotting down the compilation flags for now.
./configure --with-x --with-features=huge --enable-pythoninterp # --enable-gui
}
set_colours() {
echo 'set_colours not implemented yet, skipping..'
# ! special
# *.foreground: #f7fafc
# *.background: #1a202c
# *.cursorColor: #f7fafc
# ! black
# *.color0: #2d3748
# *.color8: #718096
# ! red
# *.color1: #f56565
# *.color9: #feb2b2
# ! green
# *.color2: #c6f6d5
# *.color10: #f0fff4
# ! yellow
# *.color3: #faf089
# *.color11: #fefcbf
# ! blue
# *.color4: #bee3f8
# *.color12: #ebfff8
# ! magenta
# *.color5: #ed64a6
# *.color13: #fbb6ce
# ! cyan
# *.color6: #4fd1c5
# *.color14: #b2f5ea
# ! white
# *.color7: #f7fafc
# *.color15: #ffffff
}
check_external_commands() {
echo 'Checking for external dependencies..'
# N.B in the event that either of these is missing AND your package manager
# can't install recent versions of this, they are not too time consuming to
# compile from source. Tmux relies on libevent, you'll also probably need
# libtool autoconf make and the usual suspects.
# Vim in particular checks for two X11 headers, Intrinsic.h and X11.h -
# Intrinsic isn't always in the same dev package (e.g in rhel, it's in
# libXt-devel
is_vim_8=$(vim --version | grep IMproved | grep -q "\s8"; is_0 $?)
echo "Is vim version 8+? $is_vim_8"
is_tmux_2=$(tmux -V| grep -q "\s\(2\|3\)"; is_0 $?)
echo "Is tmux version 2+? $is_tmux_2"
exists git
exists xmllint
exists npm
exists node
exists ruby
exists selecta # fuzzy searching utility
exists ts-node
exists wget
exists curl
exists bc # required for backward compatible tmux code
exists fd # better version of find
exists rg # ripgrep is a better version of grep
}
install_with_brew_if_missing() {
package_name="$1"
cli_to_check="$2"
if [ ! $(command -v "$cli_to_check") ]; then
brew install "$package_name"
fi
}
macos_setup() {
if [ `uname -s` = "Darwin" ]; then
echo 'this is macos'
if [ -f "/usr/bin/xcrun" ]; then
echo 'xcrun found'
else
echo 'xcrun missing, we should install xcode-tools'
xcode-select --install
fi
# disable mouse acceleration
# defaults write -g com.apple.mouse.scaling -1
# install_with_brew_if_missing bash_completion bash-completion
install_with_brew_if_missing ffmpeg ffmpeg
install_with_brew_if_missing rg rg
install_with_brew_if_missing fd fd
install_with_brew_if_missing wget wget
install_with_brew_if_missing clojure clojure
fi
}
linuxpkgs=(
ffmpeg
wget
make
openjdk-17-jdk
openjdk-17-source
maven # for deploying new clojure libs
vim-gtk # for xterm_clipboard support, in lieu of actually compiling our own version
)
# no repos for this on ubuntu by default
# rg
# fd
linux_setup() {
sudo apt-get update
sudo apt-get install $(join_by ' ' "${linuxpkgs[@]}")
# install clojure seperately
curl -O https://download.clojure.org/install/linux-install-1.10.3.998.sh
chmod +x linux-install-1.10.3.998.sh
sudo ./linux-install-1.10.3.998.sh
}
manual_steps() {
echo '!!! make sure you disable cache on google chrome'
echo '!!! make sure you disable ctrl + v as paste for windows terminal for WSL'
echo '!!! make sure you enable custom formatters under chrome devtools preferences'
}
install_win32yank() {
if [ ! -f ~/.local/bin/win32yank.exe ]; then
wget https://github.com/equalsraf/win32yank/releases/download/v0.0.4/win32yank-x64.zip -o ~/.local/bin/win32yank.zip
unzip win32yank.zip
rm ~/.local/bin/win32yank.zip
rm ~/.local/bin/README.md
rm ~/.local/bin/LICENSE
else
echo 'win32yank is already installed'
fi
}
if [ "$OS" = "Mac" ]; then
echo 'mac detected'
macos_setup
elif [ "$OS" = "Windows" ]; then
echo 'windows detected, but we must be in WSL since this is a bash script'
# linux_setup
install_win32yank
else
echo 'true linux detected, no action taken'
fi
install_config_files
configure_git
set_colours
check_external_commands
manual_steps
mkdir -p ~/.local/bin && cp ./ns ~/.local/bin