-
Notifications
You must be signed in to change notification settings - Fork 0
/
_functions_about
305 lines (255 loc) · 12.2 KB
/
_functions_about
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
#!/usr/bin/env bash
### .functions_about - display info about current system
# colors
_RED="$(tty -s && tput setaf 1)"
_YELLOW="$(tty -s && tput setaf 3)"
_WHITE="$(tty -s && tput setaf 7)"
_GRAY="$(tty -s && tput setaf 8)"
_BOLD="$(tty -s && tput bold)"
_RESET="$(tty -s && tput sgr0)"
function _anon() {
read -r str
pattern="\/Users\/$USER|\/home\/$USER"
if [[ $str =~ $pattern ]]; then
# -E argument is required for regex
echo "$str" | sed -E "s/$pattern/\$HOME/"
else
echo "$str"
fi
}
function about() {
if [ $# -ge 1 ]; then
if [ "$1" = '-f' ]; then
clear
fi
fi
# OS info
if hash neofetch 2>/dev/null; then
neofetch
else
if hash archey 2>/dev/null; then
archey -c "$1"
else
if [ -f /etc/redhat-release ]; then
cat /etc/redhat-release
else
if [ -f /etc/os-release ]; then
cat /etc/os-release
else
if [ -f /proc/version ]; then
cat /proc/version
else
uname -a
fi
fi
fi
fi
fi
if [ $# -ge 1 ]; then
if [ "$1" = '-f' ]; then
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| programming langs |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash crystal 2>/dev/null; then
echo "${_BOLD}${_YELLOW}crystal${_RESET}: ${_BOLD}${_WHITE}$(crystal --version | head -n 1 | cut -d' ' -f2)${_RESET} $(which crystal)" | _anon
else
echo "${_BOLD}${_GRAY}crystal not installed${_RESET}"
fi
if hash go 2>/dev/null; then
echo "${_BOLD}${_YELLOW}go${_RESET}: ${_BOLD}${_WHITE}$(go version | cut -d' ' -f3 | cut -d'g' -f2 | cut -d'o' -f2)${_RESET} $(which go)" | _anon
else
echo "${_BOLD}${_GRAY}go not installed${_RESET}"
fi
if hash java 2>/dev/null; then
echo "${_BOLD}${_YELLOW}java${_RESET}: ${_BOLD}${_WHITE}$(java -version 2>&1 | head -n 1 | cut -d' ' -f3- | cut -d'"' -f2 | cut -d'"' -f1)${_RESET} $(which java)" | _anon
else
echo "${_BOLD}${_GRAY}java not installed${_RESET}"
fi
if hash node 2>/dev/null; then
echo "${_BOLD}${_YELLOW}node${_RESET}: ${_BOLD}${_WHITE}$(node -v)${_RESET} $(which node)" | _anon
echo "${_BOLD}${_YELLOW}- npm${_RESET}: ${_BOLD}${_WHITE}$(npm -v)${_RESET} $(which npm)" | _anon
echo "${_BOLD}${_YELLOW}- npx${_RESET}: ${_BOLD}${_WHITE}$(npx -v)${_RESET} $(which npx)" | _anon
if hash nvm 2>/dev/null; then
echo "${_BOLD}${_YELLOW}- nvm${_RESET}: ${_BOLD}${_WHITE}$(nvm --version)${_RESET} $(which nvm)" | _anon
else
echo "${_BOLD}${_GRAY}- nvm not installed${_RESET}"
fi
if hash pnpm 2>/dev/null; then
echo "${_BOLD}${_YELLOW}- pnpm${_RESET}: ${_BOLD}${_WHITE}$(pnpm --version)${_RESET} $(which pnpm)" | _anon
else
echo "${_BOLD}${_GRAY}- pnpm not installed${_RESET}"
fi
else
echo "${_BOLD}${_GRAY}node not installed${_RESET}"
fi
if hash php 2>/dev/null; then
echo "${_BOLD}${_YELLOW}php${_RESET}: ${_BOLD}${_WHITE}$(php -v | head -1 | cut -d' ' -f2)${_RESET} $(which php)" | _anon
else
echo "${_BOLD}${_GRAY}php not installed${_RESET}"
fi
py1cmd1=$(hash python 2>/dev/null)
py1cmd2=$(type python 2>/dev/null)
if [ "$py1cmd1" ] || [ "$py1cmd2" ]; then
echo "${_BOLD}${_YELLOW}python${_RESET}: ${_BOLD}${_WHITE}$(python -c 'import sys; print(sys.version)' | cut -d' ' -f1)${_RESET} $(which python)" | _anon
else
echo "${_BOLD}${_GRAY}python not installed${_RESET}"
fi
py2cmd1=$(hash python2 2>/dev/null)
py2cmd2=$(type python2 2>/dev/null)
if [ "$py2cmd1" ] || [ "$py2cmd2" ]; then
echo "${_BOLD}${_YELLOW}python2${_RESET}: ${_BOLD}${_WHITE}$(python2 -c 'import sys; print(sys.version)' | head -1)${_RESET}$(which python2)" | _anon
else
echo "${_BOLD}${_GRAY}python2 not installed${_RESET}"
fi
if hash python3 2>/dev/null; then
echo "${_BOLD}${_YELLOW}python3${_RESET}: ${_BOLD}${_WHITE}$(python3 -c 'import sys; print(sys.version)' | cut -d' ' -f1)${_RESET} $(which python3)" | _anon
else
echo "${_BOLD}${_GRAY}python3 not installed${_RESET}"
fi
if hash ruby 2>/dev/null; then
echo "${_BOLD}${_YELLOW}ruby${_RESET}: ${_BOLD}${_WHITE}$(ruby -v | cut -d' ' -f2)${_RESET} $(which ruby)" | _anon
else
echo "${_BOLD}${_GRAY}ruby not installed${_RESET}"
fi
if hash rustc 2>/dev/null; then
echo "${_BOLD}${_YELLOW}rust${_RESET}: ${_BOLD}${_WHITE}$(rustc --version | cut -d' ' -f2)${_RESET} $(which rustc)" | _anon
else
echo "${_BOLD}${_GRAY}rustc not installed${_RESET}"
fi
if hash tsc 2>/dev/null; then
echo "${_BOLD}${_YELLOW}tsc${_RESET}: ${_BOLD}${_WHITE}$(tsc -v | cut -d' ' -f2-)${_RESET} $(which tsc)" | _anon
else
echo "${_BOLD}${_GRAY}tsc not installed${_RESET}"
fi
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| package managers |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash asdf 2>/dev/null; then
echo "${_BOLD}${_YELLOW}asdf${_RESET}: ${_BOLD}${_WHITE}$(asdf version | cut -d'v' -f2)${_RESET}" | _anon
else
echo "${_BOLD}${_GRAY}asdf not installed${_RESET}"
fi
if hash bower 2>/dev/null; then
echo "${_BOLD}${_YELLOW}bower${_RESET}: ${_BOLD}${_WHITE}$(bower -v)${_RESET} $(which bower)" | _anon
else
echo "${_BOLD}${_GRAY}bower not installed${_RESET}"
fi
if hash cargo 2>/dev/null; then
echo "${_BOLD}${_YELLOW}cargo${_RESET} ${_BOLD}${_WHITE}$(cargo --version | cut -d' ' -f2)${_RESET} $(which cargo)" | _anon
else
echo "${_BOLD}${_GRAY}cargo not installed${_RESET}"
fi
if hash composer 2>/dev/null; then
echo "${_BOLD}${_YELLOW}composer${_RESET}: ${_BOLD}${_WHITE}$(composer about | head -n 1 | cut -d' ' -f9)${_RESET} $(which composer)" | _anon
else
echo "${_BOLD}${_GRAY}composer not installed${_RESET}"
fi
if hash gem 2>/dev/null; then
echo "${_BOLD}${_YELLOW}gem${_RESET}: ${_BOLD}${_WHITE}$(gem -v)${_RESET} $(which gem)" | _anon
else
echo "${_BOLD}${_GRAY}gem not installed${_RESET}"
fi
if hash jenv 2>/dev/null; then
echo "${_BOLD}${_YELLOW}- jenv${_RESET}: ${_BOLD}${_WHITE}$(jenv --version | cut -d' ' -f2 )${_RESET}; using: $(jenv global)" | _anon
else
echo "${_BOLD}${_GRAY}jenv not installed${_RESET}"
fi
if hash mise 2>/dev/null; then
echo "${_BOLD}${_YELLOW}mise${_RESET}: ${_BOLD}${_WHITE}$(mise --version)${_RESET} $(which mise)" | _anon
else
echo "${_BOLD}${_GRAY}mise not installed${_RESET}"
fi
if hash pip 2>/dev/null; then
echo "${_BOLD}${_YELLOW}pip${_RESET}: ${_BOLD}${_WHITE}$(pip --version | cut -d' ' -f2)${_RESET} $(which pip)" | _anon
else
echo "${_BOLD}${_GRAY}pip not installed${_RESET}"
fi
if hash pip3 2>/dev/null; then
echo "${_BOLD}${_YELLOW}pip3${_RESET}: ${_BOLD}${_WHITE}$(pip3 --version | cut -d' ' -f2)${_RESET} $(which pip3)" | _anon
else
echo "${_BOLD}${_GRAY}pip3 not installed${_RESET}"
fi
if hash pyenv 2>/dev/null; then
echo "${_BOLD}${_YELLOW}pyenv${_RESET} ${_BOLD}${_WHITE}$(pyenv -v | cut -d' ' -f2 | cut -d';' -f1)${_RESET}; using: $(pyenv global)" | _anon
else
echo "${_BOLD}${_GRAY}pyenv not installed${_RESET}"
fi
if hash rbenv 2>/dev/null; then
echo "${_BOLD}${_YELLOW}rbenv${_RESET} ${_BOLD}${_WHITE}$(rbenv -v | cut -d' ' -f2)${_RESET}; using: $(rbenv global)" | _anon
else
echo "${_BOLD}${_GRAY}rbenv not installed${_RESET}"
fi
if hash yarn 2>/dev/null; then
echo "${_BOLD}${_YELLOW}yarn${_RESET}: ${_BOLD}${_WHITE}$(yarn --version)${_RESET} $(which yarn)" | _anon
else
echo "${_BOLD}${_GRAY}yarn not installed${_RESET}"
fi
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| web servers |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash httpd 2>/dev/null; then
echo "${_BOLD}${_YELLOW}httpd${_RESET}: ${_BOLD}${_WHITE}$(httpd -v | head -n 1 | cut -d : -f 2 | cut -d'/' -f2 | cut -d' ' -f1)${_RESET} $(which httpd)" | _anon
else
echo "${_BOLD}${_GRAY}httpd not installed${_RESET}"
fi
if hash nginx 2>/dev/null; then
echo "${_BOLD}${_YELLOW}nginx${_RESET}: ${_BOLD}${_WHITE}$(nginx -v 2>&1 | head -n 1 | cut -d : -f 2 | cut -d'/' -f2)${_RESET} $(which nginx)" | _anon
else
echo "${_BOLD}${_GRAY}nginx not installed${_RESET}"
fi
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| webdev tools |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash ember 2>/dev/null; then
echo "${_BOLD}${_YELLOW}ember${_RESET}: ${_BOLD}${_WHITE}$(ember -v | cut -d " " -f 2)${_RESET} $(which ember)" | _anon
else
echo "${_BOLD}${_GRAY}ember not installed${_RESET}"
fi
if hash jekyll 2>/dev/null; then
echo "${_BOLD}${_YELLOW}jekyll${_RESET}: ${_BOLD}${_WHITE}$(jekyll --version | cut -d " " -f 2)${_RESET} $(which jekyll)" | _anon
else
echo "${_BOLD}${_GRAY}jekyll not installed${_RESET}"
fi
if hash hugo 2>/dev/null; then
echo "${_BOLD}${_YELLOW}hugo${_RESET}: ${_BOLD}${_WHITE}$(hugo version | cut -d " " -f 2)${_RESET} $(which hugo)" | _anon
else
echo "${_BOLD}${_GRAY}hugo not installed${_RESET}"
fi
if hash rails 2>/dev/null; then
echo "${_BOLD}${_YELLOW}rails${_RESET}: ${_BOLD}${_WHITE}$(rails -v | cut -d' ' -f2)${_RESET} $(which rails)" | _anon
else
echo "${_BOLD}${_GRAY}- rails not installed${_RESET}"
fi
if hash symfony 2>/dev/null; then
echo "${_BOLD}${_YELLOW}symfony${_RESET}: ${_BOLD}${_WHITE}$(symfony version | cut -d' ' -f4)${_RESET} $(which symfony)" | _anon
else
echo "${_BOLD}${_GRAY}symfony not installed${_RESET}"
fi
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| database systems |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash mongod 2>/dev/null; then
echo "${_BOLD}${_YELLOW}mongod${_RESET}: ${_BOLD}${_WHITE}$(mongod --version | head -1 | cut -d' ' -f3)${_RESET} $(which mongod)" | _anon
else
echo "${_BOLD}${_GRAY}mongod not installed${_RESET}"
fi
if hash mysql 2>/dev/null; then
echo "${_BOLD}${_YELLOW}mysql${_RESET}: ${_BOLD}${_WHITE}$(mysql -V 2>&1 | cut -d' ' -f3- | cut -d',' -f1)${_RESET} $(which mysql)" | _anon
else
echo "${_BOLD}${_GRAY}mysql not installed${_RESET}"
fi
if hash psql 2>/dev/null; then
echo "${_BOLD}${_YELLOW}psql${_RESET}: ${_BOLD}${_WHITE}$(psql --version | cut -d' ' -f3)${_RESET} $(which psql)" | _anon
else
echo "${_BOLD}${_GRAY}postgres not installed${_RESET}"
fi
if hash sqlite3 2>/dev/null; then
echo "${_BOLD}${_YELLOW}sqlite3${_RESET}: ${_BOLD}${_WHITE}$(sqlite3 --version 2>&1 | cut -d' ' -f1)${_RESET} $(which sqlite3)" | _anon
else
echo "${_BOLD}${_GRAY}sqlite3 not installed${_RESET}"
fi
fi
else
echo "note: use 'about -f' for full system and application information"
fi
}