-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_functions_about
More file actions
361 lines (303 loc) · 15.2 KB
/
Copy path_functions_about
File metadata and controls
361 lines (303 loc) · 15.2 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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#!/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' && "$2" = '-c' ]]; then
clear
fi
fi
# OS info
if hash fastfetch 2>/dev/null; then
fastfetch
else
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/debian_version ]]; then
echo "Debian v$(cat /etc/debian_version)"
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
fi
fi
if [[ -f /etc/debian_version ]]; then
echo "Debian v$(cat /etc/debian_version)"
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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v node)" | _anon
echo "${_BOLD}${_YELLOW}- npm${_RESET}: ${_BOLD}${_WHITE}$(npm -v)${_RESET} $(command -v npm)" | _anon
echo "${_BOLD}${_YELLOW}- npx${_RESET}: ${_BOLD}${_WHITE}$(npx -v)${_RESET} $(command -v npx)" | _anon
if hash nvm 2>/dev/null; then
echo "${_BOLD}${_YELLOW}- nvm${_RESET}: ${_BOLD}${_WHITE}$(nvm --version)${_RESET} $(command -v 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} $(command -v 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} $(command -v php)" | _anon
else
echo "${_BOLD}${_GRAY}php [not installed]${_RESET}"
fi
pycmd1=$(hash python 2>/dev/null)
pycmd2=$(type python 2>/dev/null)
pycmd3=$(hash python2 2>/dev/null)
pycmd4=$(type python2 2>/dev/null)
pycmd5=$(hash python3 2>/dev/null)
pycmd6=$(type python3 2>/dev/null)
if [[ -n "${pycmd1}" ]] || [[ -n "${pycmd2}" ]] || [[ -n "${pycmd3}" ]] || [[ -n "${pycmd4}" ]] || [[ -n "${pycmd5}" ]] || [[ -n "${pycmd6}" ]]; then
echo "${_BOLD}${_YELLOW}python${_RESET}: ${_BOLD}${_WHITE}$(python -c 'import sys; print(sys.version)' | cut -d' ' -f1)${_RESET} $(command -v python)" | _anon
else
echo "${_BOLD}${_GRAY}python [not installed]${_RESET}"
fi
# py2cmd1=$(hash python2 2>/dev/null)
# py2cmd2=$(type python2 2>/dev/null)
# if [[ -n "${py2cmd1}" ]] || [[ -n "${py2cmd2}" ]]; then
# echo "${_BOLD}${_YELLOW}python2${_RESET}: ${_BOLD}${_WHITE}$(python2 -c 'import sys; print(sys.version)' | head -1)${_RESET}$(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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 uv 2>/dev/null; then
echo "${_BOLD}${_YELLOW}uv${_RESET}: ${_BOLD}${_WHITE}$(uv --version | cut -d' ' -f2 | cut -d';' -f1)${_RESET}; $(command -v uv)" | _anon
else
echo "${_BOLD}${_GRAY}uv [not installed]${_RESET}"
fi
if hash yarn 2>/dev/null; then
echo "${_BOLD}${_YELLOW}yarn${_RESET}: ${_BOLD}${_WHITE}$(yarn --version)${_RESET} $(command -v 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} $(command -v 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} $(command -v nginx)" | _anon
else
echo "${_BOLD}${_GRAY}nginx [not installed]${_RESET}"
fi
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| mail servers |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash dovecot 2>/dev/null; then
echo "${_BOLD}${_YELLOW}dovecot${_RESET}: ${_BOLD}${_WHITE}$(dovecot --version)${_RESET} $(command -v dovecot)" | _anon
else
echo "${_BOLD}${_GRAY}dovecot [not installed]${_RESET}"
fi
if hash postfix 2>/dev/null; then
echo "${_BOLD}${_YELLOW}postfix${_RESET}: ${_BOLD}${_WHITE}$(postconf -d mail_version 2>&1 | grep -v 'Permission denied' | cut -d'=' -f2 | cut -d' ' -f2)${_RESET} $(command -v postfix)" | _anon
else
echo "${_BOLD}${_GRAY}postfix [not installed]${_RESET}"
fi
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
echo "${_BOLD}${_WHITE}| webdev tools |${_RESET}"
echo "${_BOLD}${_WHITE}--------------------------------${_RESET}"
if hash ddev 2>/dev/null; then
echo "${_BOLD}${_YELLOW}ddev${_RESET}: ${_BOLD}${_WHITE}$(ddev -v | cut -d " " -f 3)${_RESET} $(command -v ddev)" | _anon
else
echo "${_BOLD}${_GRAY}ddev [not installed]${_RESET}"
fi
if hash ember 2>/dev/null; then
echo "${_BOLD}${_YELLOW}ember${_RESET}: ${_BOLD}${_WHITE}$(ember -v | cut -d " " -f 2)${_RESET} $(command -v ember)" | _anon
else
echo "${_BOLD}${_GRAY}ember [not installed]${_RESET}"
fi
if hash fin 2>/dev/null; then
echo "${_BOLD}${_YELLOW}docksal${_RESET}: ${_BOLD}${_WHITE}$(fin -v | cut -d " " -f 2)${_RESET} $(command -v fin)" | _anon
else
echo "${_BOLD}${_GRAY}docksal [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} $(command -v hugo)" | _anon
else
echo "${_BOLD}${_GRAY}hugo [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} $(command -v jekyll)" | _anon
else
echo "${_BOLD}${_GRAY}jekyll [not installed]${_RESET}"
fi
if hash rails 2>/dev/null; then
echo "${_BOLD}${_YELLOW}rails${_RESET}: ${_BOLD}${_WHITE}$(rails -v | cut -d' ' -f2)${_RESET} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v 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} $(command -v psql)" | _anon
else
echo "${_BOLD}${_GRAY}postgres [not installed]${_RESET}"
fi
if hash redis-server 2>/dev/null; then
echo "${_BOLD}${_YELLOW}redis${_RESET}: ${_BOLD}${_WHITE}$(redis-server --version 2>&1 | cut -d' ' -f3 | cut -d'=' -f2)${_RESET} $(command -v redis-server)" | _anon
else
echo "${_BOLD}${_GRAY}redis [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} $(command -v 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
}