Skip to content

Commit 046f787

Browse files
feat: ✨ Allow switching between font variants
Closes #51
1 parent 1913f02 commit 046f787

File tree

2 files changed

+158
-82
lines changed

2 files changed

+158
-82
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
A POSIX \*nix (Linux, macOS, Android, BSD, etc) fetch script using Nerdfonts
33

44
![Screenshot](https://github.com/ThatOneCalculator/NerdFetch/assets/44733677/0bc8872f-70b0-485f-a5f5-cc45bb2dac79)
5+
![Phosphor](https://github.com/ThatOneCalculator/NerdFetch/assets/44733677/fa620df5-af93-4145-adbf-d2c0be279851)
6+
![Cozette](https://github.com/ThatOneCalculator/NerdFetch/assets/44733677/f7999fb1-53c3-4427-91cc-5aa3e42aeb41)
57

68
### Dependencies
79

8-
- [Any Nerdfonts font](https://www.nerdfonts.com/font-downloads)
10+
- [Any Nerdfonts font](https://www.nerdfonts.com/font-downloads), [Cozette](https://github.com/slavfox/Cozette), or [Phosphor](https://github.com/phosphor-icons/homepage/releases/tag/v2.0.0)
911
- POSIX-compliant shell
1012
- `which`
1113
- Anything but Windows
@@ -14,6 +16,12 @@
1416

1517
[![Packaging status](https://repology.org/badge/vertical-allrepos/nerdfetch.svg)](https://repology.org/project/nerdfetch/versions)
1618

19+
#### How to switch fonts
20+
21+
- Nerdfonts is used by default
22+
- Use `-c` for Cozette
23+
- Use `-p` for Phosphor
24+
1725
#### [Arch Linux](https://aur.archlinux.org/packages/nerdfetch/):
1826

1927
```sh

nerdfetch

Lines changed: 149 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,38 @@
33
## OS/ENVIRONMENT INFO DETECTION
44

55
ostype="$(uname)"
6-
osi=""
76

7+
version=8.0.0
8+
font=nerd
89
distrotype=none
10+
osi=""
11+
ki=""
12+
ri="󰍛"
13+
pi="󰏔"
14+
ui="󰅶"
15+
ci=""
16+
17+
case $1 in
18+
"-p")
19+
font=phosphor;
20+
osi="";
21+
ki=""
22+
ri=""
23+
pi=""
24+
ui=""
25+
ci="";;
26+
"-c")
27+
font=cozette
28+
ki=""
29+
ri=""
30+
pi=""
31+
ui=""
32+
ci="";;
33+
"-v") echo "NerdFetch $version"; exit;;
34+
"-h") echo "-p: Phosphor font
35+
-c: Cozette font
36+
-v: Version"; exit;;
37+
esac
938

1039
if command -v getprop 1> /dev/null; then
1140
distrotype=android
@@ -17,47 +46,70 @@ case $ostype in
1746
host="$(hostname)"
1847
USER=${USER:-$(id -un || printf %s "${HOME/*\/}")}
1948
os="Android $(getprop ro.build.version.release)"
20-
osi="󰀲"
49+
if [ $font = phosphor ]; then
50+
osi=""
51+
else
52+
osi="󰀲"
53+
fi
2154
else
2255
host="$(cat /proc/sys/kernel/hostname)"
2356
. /etc/os-release
2457
if [ -f /bedrock/etc/bedrock-release ]; then
2558
os="$(brl version)"
2659
else
2760
os="${PRETTY_NAME}"
28-
case $(echo $ID | sed 's/ .*//') in
29-
debian) osi="";;
30-
arch) osi="󰣇";;
31-
endeavouros) osi="";;
32-
fedora) osi="";;
33-
gentoo) osi="";;
34-
rhel) osi="";;
35-
slackware) osi="";;
36-
void) osi="";;
37-
alpine) osi="";;
38-
nixos) osi="󱄅";;
39-
artix) osi="";;
40-
exherbo) osi="󰆚";;
41-
mageia) osi="";;
42-
manjaro) osi="";;
43-
opensuse) osi="";;
44-
solus) osi="";;
45-
ubuntu) osi="";;
46-
mint) osi="󰣭";;
47-
trisquel) osi="";;
48-
puppy) osi="";;
49-
coreos) osi="";;
50-
mx) osi="";;
51-
vanilla) osi="";;
52-
pop_os) osi="";;
53-
raspbian) osi="";;
54-
deepin) osi="";;
55-
almalinux) osi="";;
56-
garuda) osi="";;
57-
centos) osi="";;
58-
rocky) osi="";;
59-
*) osi="";;
60-
esac
61+
if [ $font = nerd ]; then
62+
case $(echo $ID | sed 's/ .*//') in
63+
debian) osi="";;
64+
arch) osi="󰣇";;
65+
endeavouros) osi="";;
66+
fedora) osi="";;
67+
gentoo) osi="";;
68+
rhel) osi="";;
69+
slackware) osi="";;
70+
void) osi="";;
71+
alpine) osi="";;
72+
nixos) osi="󱄅";;
73+
artix) osi="";;
74+
exherbo) osi="󰆚";;
75+
mageia) osi="";;
76+
manjaro) osi="";;
77+
opensuse) osi="";;
78+
solus) osi="";;
79+
ubuntu) osi="";;
80+
mint) osi="󰣭";;
81+
trisquel) osi="";;
82+
puppy) osi="";;
83+
coreos) osi="";;
84+
mx) osi="";;
85+
vanilla) osi="";;
86+
pop_os) osi="";;
87+
raspbian) osi="";;
88+
deepin) osi="";;
89+
almalinux) osi="";;
90+
garuda) osi="";;
91+
centos) osi="";;
92+
rocky) osi="";;
93+
esac
94+
elif [ $font = cozette ]; then
95+
case $(echo $ID | sed 's/ .*//') in
96+
debian) osi="";;
97+
arch) osi="";;
98+
fedora) osi="";;
99+
gentoo) osi="";;
100+
slackware) osi="";;
101+
void) osi="";;
102+
alpine) osi="";;
103+
nixos) osi="";;
104+
mageia) osi="";;
105+
manjaro) osi="";;
106+
opensuse) osi="";;
107+
ubuntu) osi="";;
108+
mint) osi="";;
109+
coreos) osi="";;
110+
centos) osi="";;
111+
esac
112+
fi
61113
fi
62114
fi
63115
shell=$(basename "$SHELL");;
@@ -66,22 +118,38 @@ case $ostype in
66118
mac_product="$(/usr/libexec/PlistBuddy -c "Print:ProductName" /System/Library/CoreServices/SystemVersion.plist)"
67119
mac_version="$(/usr/libexec/PlistBuddy -c "Print:ProductVersion" /System/Library/CoreServices/SystemVersion.plist)"
68120
os="${mac_product} ${mac_version}"
69-
osi="";;
121+
case $font in
122+
nerd) osi="";;
123+
phosphor) osi="";;
124+
cozette) osi="";;
125+
esac;;
70126
*"FreeBSD"*)
71127
host="$(hostname)"
72128
distrotype=bsd
73129
os="FreeBSD $(freebsd-version | sed 's/-.*//')"
74-
osi="";;
130+
case $font in
131+
nerd) osi="";;
132+
phosphor) osi="";;
133+
cozette) osi="";;
134+
esac;;
75135
*"OpenBSD"*)
76136
host="$(hostname)"
77137
distrotype=bsd
78138
os="OpenBSD $(uname -r)"
79-
osi="";;
139+
case $font in
140+
nerd) osi="";;
141+
phosphor) osi="";;
142+
cozette) osi="";;
143+
esac;;
80144
*"NetBSD"*)
81145
host="$(hostname)"
82-
distrotype=bsd
146+
distrotype=netbsd
83147
os="NetBSD $(uname -r)"
84-
osi="󰉀";;
148+
case $font in
149+
nerd) osi="󰉀";;
150+
phosphor) osi="";;
151+
cozette) osi="";;
152+
esac;;
85153
*)
86154
os="Unix-like"
87155
host="host"
@@ -91,7 +159,7 @@ esac
91159

92160
MANAGER=$(which nix-env pkg yum zypper dnf rpm dpkg-query brew port pacman xbps-query emerge cave apk kiss pmm /usr/sbin/slackpkg bulge yay paru pacstall cpm pmm eopkg getprop 2>/dev/null)
93161
manager=$(basename "$MANAGER")
94-
if [ $osi = "󰉀" ]; then
162+
if [ $distrotype = netbsd ]; then
95163
manager="pkg_info-netbsd"
96164
fi
97165
case $manager in
@@ -140,43 +208,43 @@ manager=$(echo $manager | sed "s/-query//; s/\/usr\/.*\///")
140208
## UPTIME DETECTION
141209

142210
if [ $distrotype = android ]; then
143-
uptime="$(echo $(uptime -p) | cut -c 4-)"
144-
elif [ $distrotype = bsd ]; then
211+
uptime="$(echo $(uptime -p) | cut -c 4-)"
212+
elif [ $distrotype = bsd ] || [ $distrotype = netbsd ]; then
145213
uptime="$(uptime | sed -e 's/.* up //; s/, [0-9]* user.*//')"
146214
else
147-
case $ostype in
148-
*"Linux"*)
149-
IFS=. read -r s _ < /proc/uptime;;
150-
*"NetBSD"*)
151-
s=$(/sbin/sysctl -n kern.boottime)
152-
s=${s#*=}
153-
s=${s%,*}
154-
s=$(($(date +%s) - s));;
155-
*)
156-
s=$(sysctl -n kern.boottime)
157-
s=${s#*=}
158-
s=${s%,*}
159-
s=$(($(date +%s) - s));;
160-
esac
161-
d="$((s / 60 / 60 / 24))"
162-
h="$((s / 60 / 60 % 24))"
163-
m="$((s / 60 % 60))"
164-
# Plurals
165-
[ "$d" -gt 1 ] && dp=s
166-
[ "$h" -gt 1 ] && hp=s
167-
[ "$m" -gt 1 ] && mp=s
168-
[ "$s" -gt 1 ] && sp=s
169-
# Hide empty fields.
170-
[ "$d" = 0 ] && d=
171-
[ "$h" = 0 ] && h=
172-
[ "$m" = 0 ] && m=
173-
[ "$m" != "" ] && s=
174-
# Make the output of uptime smaller.
175-
[ "$d" ] && uptime="$d day$dp, "
176-
[ "$h" ] && uptime="$uptime$h hour$hp, "
177-
[ "$m" ] && uptime="$uptime$m min$mp"
178-
[ "$s" ] && uptime="$uptime$s sec$sp"
179-
uptime=${uptime%, }
215+
case $ostype in
216+
*"Linux"*)
217+
IFS=. read -r s _ < /proc/uptime;;
218+
*"NetBSD"*)
219+
s=$(/sbin/sysctl -n kern.boottime)
220+
s=${s#*=}
221+
s=${s%,*}
222+
s=$(($(date +%s) - s));;
223+
*)
224+
s=$(sysctl -n kern.boottime)
225+
s=${s#*=}
226+
s=${s%,*}
227+
s=$(($(date +%s) - s));;
228+
esac
229+
d="$((s / 60 / 60 / 24))"
230+
h="$((s / 60 / 60 % 24))"
231+
m="$((s / 60 % 60))"
232+
# Plurals
233+
[ "$d" -gt 1 ] && dp=s
234+
[ "$h" -gt 1 ] && hp=s
235+
[ "$m" -gt 1 ] && mp=s
236+
[ "$s" -gt 1 ] && sp=s
237+
# Hide empty fields.
238+
[ "$d" = 0 ] && d=
239+
[ "$h" = 0 ] && h=
240+
[ "$m" = 0 ] && m=
241+
[ "$m" != "" ] && s=
242+
# Make the output of uptime smaller.
243+
[ "$d" ] && uptime="$d day$dp, "
244+
[ "$h" ] && uptime="$uptime$h hour$hp, "
245+
[ "$m" ] && uptime="$uptime$m min$mp"
246+
[ "$s" ] && uptime="$uptime$s sec$sp"
247+
uptime=${uptime%, }
180248
fi
181249

182250
## RAM DETECTION
@@ -253,9 +321,9 @@ cat <<EOF
253321
254322
${c0} ___ ${nc}${USER}${red}@${reset}${hn}${host}${reset}
255323
${c0} (${c1}.. ${c0}\ ${lc}${osi} ${ic}${os}${reset}
256-
${c0} (${c2}<> ${c0}| ${lc} ${ic}${kernel}${reset}
257-
${c0} /${c1}/ \\ ${c0}\\ ${lc}󰍛 ${ic}${RAM}${memstat} ${mempercent}
258-
${c0} ( ${c1}| | ${c0}/| ${lc}󰏔 ${ic}${packages} (${manager})${reset}
259-
${c2} _${c0}/\\ ${c1}__)${c0}/${c2}_${c0}) ${lc}󰅶 ${ic}${uptime}${reset}
260-
${c2} \/${c0}-____${c2}\/${reset} ${lc} ${red}███${green}███${yellow}███${blue}███${magenta}███${cyan}███${reset}
324+
${c0} (${c2}<> ${c0}| ${lc}${ki} ${ic}${kernel}${reset}
325+
${c0} /${c1}/ \\ ${c0}\\ ${lc}${ri} ${ic}${RAM}${memstat} ${mempercent}
326+
${c0} ( ${c1}| | ${c0}/| ${lc}${pi} ${ic}${packages} (${manager})${reset}
327+
${c2} _${c0}/\\ ${c1}__)${c0}/${c2}_${c0}) ${lc}${ui} ${ic}${uptime}${reset}
328+
${c2} \/${c0}-____${c2}\/${reset} ${lc}${ci} ${red}███${green}███${yellow}███${blue}███${magenta}███${cyan}███${reset}
261329
EOF

0 commit comments

Comments
 (0)