-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout.fish
110 lines (92 loc) · 3.82 KB
/
about.fish
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
function about -d 'Shows information about this Mac'
# NOTE: Decided to make my own logo instead of using variants from Neofetch
# NOTE: All symbols are Braille, so there are no spaces in it
set -l logo \
'⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⡟⠀⠀⠀⠀⠀' \
'⠀⠀⠀⠀⠀⠀⠀⠀⣼⡿⠋⠀⠀⠀⠀⠀⠀' \
'⠀⠀⢀⣾⣿⣿⣿⣷⣶⣾⣿⣿⣿⣿⣦⠀⠀' \
'⠀⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀' \
'⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀' \
'⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀' \
'⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁⠀' \
'⠀⠀⠀⠈⠻⣿⣿⡿⠿⢿⣿⣿⣿⡿⠁⠀⠀'
set logo_length (string length --visible $logo[-1])
# CPU can be found here as well
set -l product (
ioreg -rd1 -c IOPlatformDevice -k product-name \
| rg -or '$1' 'product-name.*<"(.+)">'
)
set -l model (sysctl -n hw.model)
set -l cpu (sysctl -n machdep.cpu.brand_string)
set -l memory (math (sysctl -n hw.memsize) / 1024^3) 'GB'
# model can be found here as well
set -l serial (
ioreg -rd1 -c IOPlatformExpertDevice -k IOPlatformSerialNumber \
| rg -or '$1' 'IOPlatformSerialNumber.*"(.*)"'
)
set -l os (sw_vers | rg -o '[\w\d.]+$')
set -l codename (
head -n30 '/Library/Documentation/License.lpdf/Contents/Resources/English.lproj/License.html' \
| rg -or '$1' 'macOS ([\w\s]+)<'
)
set -l display (
system_profiler SPDisplaysDataType \
| rg -or '$2' '(Display Type|Resolution): (.*)$'
)
set -l display[1] (string trim (string replace -ira 'built-in|display' '' $display[1]))
set -l display[2] (string trim (string replace -ia 'retina' '' $display[2]))
set -l info \
"$(whoami)@$(hostname -s)" \
"Host: $product" \
"Model: $model" \
"Chip: $cpu" \
"Memory: $memory" \
"Serial: $serial" \
"$os[1]: $codename $os[2] ($os[3])" \
"Display: $display[1] ($display[2])"
set -l logo_colored
set -l logo_line 1
# NOTE: 8-bit (xterm-256color) compatible logo colors
for color in '5faf5f' '5faf5f' '5faf5f' 'ffaf00' 'ff8700' 'd75f5f' '875f87' '00afd7'
set -a logo_colored \
(echo -s (set_color $color) $logo[$logo_line] (set_color normal))
set -l logo_line (math $logo_line + 1)
end
set -l info_line 1
for line in $info
echo -e $logo_colored[$info_line] $info[$info_line]
set -l info_line (math $info_line + 1)
end
echo
set -l term (string replace '_' ' ' (string replace '.app' '' $TERM_PROGRAM))
set -l shell (path basename $SHELL)
set -l term_info \
"Shell: $shell" \
"Terminal: $term ($TERM)"
for line in $term_info
string pad --width (math $logo_length + (string length --visible $line) + 1) \
$line
end
set -l term_colors
set -l term_colors_bright
set -l term_colors_block ' ' # simply three spaces and no Unicode symbols
set -l term_colors_block_length (string length --visible $term_colors_block)
for color in 'black' 'red' 'green' 'yellow' 'blue' 'magenta' 'cyan' 'white'
set -a term_colors \
(echo -s (set_color --background $color) \
$term_colors_block \
(set_color normal))
set -a term_colors_bright \
(echo -s (set_color --background br$color) \
$term_colors_block \
(set_color normal))
end
set -l term_colors (echo -s $term_colors)
set -l term_colors_bright (echo -s $term_colors_bright)
set -l term_colors_padding (
math $logo_length + $(string length --visible $term_colors) + 1
)
string pad --width $term_colors_padding \
$term_colors \
$term_colors_bright
end