├── LICENSE ├── README.md └── nerdfetch /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2024 Kainoa Kanter 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NerdFetch 2 | A POSIX \*nix (Linux, macOS, Android, BSD, etc) fetch script using Nerdfonts (and others) 3 | 4 | *Nerdfont* 5 | 6 | ![Screenshot](https://github.com/ThatOneCalculator/NerdFetch/assets/44733677/37ea2a01-80e1-457b-b922-89cc708c527e) 7 | 8 | *Phosphor Bold* 9 | 10 | ![Phosphor](https://github.com/ThatOneCalculator/NerdFetch/assets/44733677/07d2cc29-5a58-4a00-8a52-95ec2032988b) 11 | 12 | *Cozette* 13 | 14 | ![Cozette](https://github.com/ThatOneCalculator/NerdFetch/assets/44733677/574e8417-adee-45cd-9a4e-68661240f458) 15 | 16 | ### Dependencies 17 | 18 | - [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) 19 | - [POSIX.1-2017 compliant shell](#shells-tested) 20 | - [Anything but Windows](#oses-tested) 21 | 22 | ### To install and run 23 | 24 | [![Packaging status](https://repology.org/badge/vertical-allrepos/nerdfetch.svg)](https://repology.org/project/nerdfetch/versions) 25 | 26 | #### How to switch fonts 27 | 28 | - Nerdfonts is used by default 29 | - Use `-c` for Cozette 30 | - Use `-p` for Phosphor 31 | - Use `-e` for Emojis 32 | 33 | #### [Arch Linux (AUR)](https://aur.archlinux.org/packages/nerdfetch/) 34 | 35 | ```sh 36 | yay -S nerdfetch # -git 37 | nerdfetch 38 | ``` 39 | Make sure to replace `yay` with whatever AUR helper you use. 40 | 41 | #### [macOS (homebrew)](https://formulae.brew.sh/formula/nerdfetch) 42 | 43 | ```sh 44 | brew install nerdfetch 45 | nerdfetch 46 | ``` 47 | 48 | #### [Nix](https://search.nixos.org/packages?show=nerdfetch) 49 | 50 | ```sh 51 | nix-shell -p nerdfetch 52 | nerdfetch 53 | ``` 54 | 55 | #### [Gentoo (GURU)](https://gpo.zugaina.org/Overlays/guru/app-misc/nerdfetch)/[LiGurOS](https://gitlab.com/liguros/liguros-repo/-/tree/stable/app-misc/nerdfetch) 56 | 57 | Add the GURU overlay: (*Not needed for LiGurOS*) 58 | 59 | ```sh 60 | emerge nerdfetch 61 | nerdfetch 62 | ``` 63 | #### [yiffOS](https://packages.yiffos.gay/nerdfetch) 64 | 65 | ```sh 66 | bulge install nerdfetch 67 | nerdfetch 68 | ``` 69 | 70 | #### [BirbOS](https://github.com/birb-linux/BirbOS-packages/tree/dev/nerdfetch) 71 | 72 | ```sh 73 | sudo birb nerdfetch 74 | nerdfetch 75 | ``` 76 | 77 | #### Manually 78 | 79 | Copy-paste this into your terminal: 80 | 81 | ```sh 82 | sudo curl -fsSL https://raw.githubusercontent.com/ThatOneCalculator/NerdFetch/main/nerdfetch -o /usr/bin/nerdfetch 83 | sudo chmod +x /usr/bin/nerdfetch 84 | nerdfetch 85 | ``` 86 | 87 | #### Android with Termux 88 | 89 | Copy-paste this into Termux: 90 | 91 | ```sh 92 | curl -fsSL https://raw.githubusercontent.com/ThatOneCalculator/NerdFetch/main/nerdfetch -o /data/data/com.termux/files/usr/bin/nerdfetch 93 | chmod a+x /data/data/com.termux/files/usr/bin/nerdfetch 94 | nerdfetch 95 | ``` 96 | 97 | #### Run once 98 | 99 | Note that this will ***not*** install the program. 100 | 101 | ```sh 102 | curl -fsSL https://raw.githubusercontent.com/ThatOneCalculator/NerdFetch/main/nerdfetch | sh 103 | ``` 104 | 105 | ### Features 106 | 107 | - Strong cross-OS compatability 108 | - Not bloated 109 | - Portable 110 | - POSIX 111 | 112 | ### OSes tested 113 | 114 | - Debian based Linux 115 | - Ubuntu based Linux 116 | - Arch based Linux 117 | - Gentoo based Linux 118 | - RedHat based Linux 119 | - OpenSUSE based Linux 120 | - Bedrock Linux 121 | - Alpine Linux 122 | - KISS Linux 123 | - Void Linux 124 | - Exherbo Linux 125 | - NixOS Linux 126 | - Solus Linux 127 | - yiffOS Linux 128 | - Slackware Linux 129 | - BirbOS Linux 130 | - macOS 131 | - Android 132 | - FreeBSD 133 | - OpenBSD 134 | - NetBSD 135 | - OpenWrt 136 | 137 | ### Shells tested 138 | 139 | - Bourne Again Shell (`bash`) 140 | - Z Shell (`zsh`) 141 | - Almquist Shell (`ash`), Debian Almquist Shell (`dash`) 142 | - KornShell (`ksh`), MirBSD KornShell (`mksh`) 143 | - Oil Shell (`osh`) 144 | - Yet Another Shell (`yash`) 145 | 146 | ### Known issue(s) 147 | 148 | - `nsh` is currently unsupported (https://github.com/ThatOneCalculator/NerdFetch/issues/46) 149 | -------------------------------------------------------------------------------- /nerdfetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ## OS/ENVIRONMENT INFO DETECTION 4 | 5 | ostype="$(uname)" 6 | 7 | version=8.4.2 8 | font=nerd 9 | 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 | ;; 27 | "-c") 28 | font=cozette 29 | ki="♥" 30 | ri="" 31 | pi="" 32 | ui="" 33 | ci="" 34 | ;; 35 | "-e") 36 | font=emoji 37 | osi="🐧" 38 | ki="💓" 39 | ri="🐐" 40 | pi="📦" 41 | ui="☕" 42 | ci="🎨" 43 | ;; 44 | "-v") 45 | echo "NerdFetch $version" 46 | exit 47 | ;; 48 | "-h"|"--help") 49 | echo "Flags: 50 | -c: Cozette font 51 | -p: Phosphor font 52 | -e: Emoji font 53 | -v: Version" 54 | exit 55 | ;; 56 | esac 57 | 58 | if command -v getprop 1>/dev/null 2>&1; then 59 | distrotype=android 60 | fi 61 | kernel=$(uname -r) 62 | kernel=${kernel%%-*} 63 | case $ostype in 64 | *"Linux"*) 65 | if [ $distrotype = android ]; then 66 | host="$(hostname)" 67 | USER="$(whoami)" 68 | os="Android $(getprop ro.build.version.release)" 69 | case $font in 70 | phosphor) osi="" ;; 71 | emoji) osi="🤖" ;; 72 | *) osi="󰀲" ;; 73 | esac 74 | else 75 | host="$(cat /proc/sys/kernel/hostname)" 76 | . /etc/os-release 77 | if [ -f /bedrock/etc/bedrock-release ]; then 78 | os="$(brl version)" 79 | else 80 | os="${PRETTY_NAME}" 81 | if [ $font = nerd ]; then 82 | case ${ID%% *} in 83 | debian) osi="" ;; 84 | arch) osi="󰣇" ;; 85 | endeavouros) osi="" ;; 86 | fedora) osi="" ;; 87 | gentoo) osi="" ;; 88 | rhel) osi="" ;; 89 | slackware) osi="" ;; 90 | void) osi="" ;; 91 | alpine) osi="" ;; 92 | nixos) osi="󱄅" ;; 93 | artix) osi="" ;; 94 | exherbo) osi="󰆚" ;; 95 | mageia) osi="" ;; 96 | manjaro) osi="" ;; 97 | opensuse) osi="" ;; 98 | solus) osi="" ;; 99 | ubuntu) osi="" ;; 100 | linuxmint) osi="󰣭" ;; 101 | trisquel) osi="" ;; 102 | puppy) osi="" ;; 103 | coreos) osi="" ;; 104 | mx) osi="" ;; 105 | vanilla) osi="" ;; 106 | pop_os) osi="" ;; 107 | raspbian) osi="" ;; 108 | deepin) osi="" ;; 109 | almalinux) osi="" ;; 110 | garuda) osi="" ;; 111 | centos) osi="" ;; 112 | rocky) osi="" ;; 113 | esac 114 | elif [ $font = cozette ]; then 115 | case ${ID%% *} in 116 | debian) osi="" ;; 117 | arch) osi="" ;; 118 | fedora) osi="" ;; 119 | gentoo) osi="" ;; 120 | slackware) osi="" ;; 121 | void) osi="" ;; 122 | alpine) osi="" ;; 123 | nixos) osi="" ;; 124 | mageia) osi="" ;; 125 | manjaro) osi="" ;; 126 | opensuse) osi="" ;; 127 | ubuntu) osi="" ;; 128 | linuxmint) osi="" ;; 129 | coreos) osi="" ;; 130 | centos) osi="" ;; 131 | esac 132 | fi 133 | fi 134 | fi 135 | ;; 136 | *"Darwin"*) 137 | host="$(hostname -f | sed -e 's/^[^.]*\.//')" 138 | mac_product="$(/usr/libexec/PlistBuddy -c "Print:ProductName" /System/Library/CoreServices/SystemVersion.plist)" 139 | mac_version="$(/usr/libexec/PlistBuddy -c "Print:ProductVersion" /System/Library/CoreServices/SystemVersion.plist)" 140 | os="${mac_product} ${mac_version}" 141 | case $font in 142 | nerd) osi="" ;; 143 | phosphor) osi="" ;; 144 | cozette) osi="" ;; 145 | emoji) osi="🍎" ;; 146 | esac 147 | ;; 148 | *"FreeBSD"*) 149 | host="$(hostname)" 150 | distrotype=bsd 151 | os="FreeBSD $(freebsd-version | sed 's/-.*//')" 152 | case $font in 153 | nerd) osi="" ;; 154 | phosphor) osi="" ;; 155 | cozette) osi="" ;; 156 | emoji) osi="😈" ;; 157 | esac 158 | ;; 159 | *"OpenBSD"*) 160 | host="$(hostname)" 161 | distrotype=bsd 162 | os="OpenBSD $(uname -r)" 163 | case $font in 164 | nerd) osi="" ;; 165 | phosphor) osi="" ;; 166 | cozette) osi="⌘" ;; 167 | emoji) osi="🐡" ;; 168 | esac 169 | ;; 170 | *"NetBSD"*) 171 | host="$(hostname)" 172 | distrotype=netbsd 173 | os="NetBSD $(uname -r)" 174 | case $font in 175 | nerd) osi="󰉀" ;; 176 | phosphor) osi="" ;; 177 | cozette) osi="" ;; 178 | emoji) osi="🚩" ;; 179 | esac 180 | ;; 181 | *) 182 | os="Unix-like" 183 | host="host" 184 | ;; 185 | esac 186 | 187 | ## PACKAGE MANAGER AND PACKAGES DETECTION 188 | 189 | MANAGER=$(for x in nix-env pkg flatpak yum zypper dnf rpm dpkg-query brew port pacman xbps-query emerge cave apk kiss pmm /usr/sbin/slackpkg bulge birb yay paru pacstall cpm pmm opkg eopkg getprop; do command -v $x; done 2>/dev/null) 190 | manager=${MANAGER##*/} 191 | if [ $distrotype = netbsd ]; then 192 | manager="pkg_info-netbsd" 193 | fi 194 | case $manager in 195 | cpm) packages="$(cpm C)" ;; 196 | flatpak) packages="$(flatpak list --app | wc -l)" ;; 197 | brew) packages="$(printf '%s\n' "$(brew --cellar)/"* | wc -l)" ;; 198 | port) packages="$(($(port installed | wc -l) - 1))" ;; 199 | dpkg-query) packages="$(dpkg-query -f '${binary:Package}\n' -W | wc -l)" ;; 200 | rpm) packages="$(rpm -qa --last | wc -l)" ;; 201 | yum) packages="$(yum list installed | wc -l)" ;; 202 | dnf) packages="$(dnf list installed | wc -l)" ;; 203 | zypper) packages="$(zypper se | wc -l)" ;; 204 | pacman) packages="$(pacman -Q | wc -l)" ;; 205 | yay) packages="$(yay -Q | wc -l)" ;; 206 | paru) packages="$(paru -Q | wc -l)" ;; 207 | pacstall) packages="$(pacstall -L | wc -l)" ;; 208 | kiss) packages="$(kiss list | wc -l)" ;; 209 | emerge) packages="$(qlist -I | wc -l)" ;; 210 | pkg) packages="$(pkg info | wc -l | tr -d ' ')" ;; 211 | cave) packages="$(cave show installed-slots | wc -l)" ;; 212 | xbps-query) packages="$(xbps-query -l | wc -l)" ;; 213 | nix-env) packages="$(nix-store -q --requisites /run/current-system/sw | wc -l)" ;; 214 | apk) packages="$(apk list --installed | wc -l)" ;; 215 | pmm) packages="$(/bedrock/libexec/pmm pacman pmm -Q 2>/dev/null | wc -l)" ;; 216 | opkg) packages="$(opkg list-installed | wc -l)" ;; 217 | eopkg) packages="$(eopkg li | wc -l)" ;; 218 | slackpkg) packages="$(ls /var/log/packages | wc -l)" ;; 219 | bulge) packages="$(bulge list | wc -l)" ;; 220 | birb) packages="$(birb --list-installed | wc -l)" ;; 221 | pkg_info) 222 | packages="$(pkg_info -A | wc -l)" 223 | manager="pkg" 224 | ;; 225 | pkg_info-netbsd) 226 | packages="$(pkg_info -a | wc -l)" 227 | manager="pkg" 228 | ;; 229 | *) 230 | if [ $distrotype = android ]; then 231 | packages="$(pkg list-installed 2>/dev/null | wc -l)" 232 | manager="pkg" 233 | else 234 | packages="$(ls /usr/bin | wc -l)" 235 | manager="bin" 236 | fi 237 | ;; 238 | esac 239 | 240 | packages="${packages#"${packages%%[![:space:]]*}"}" 241 | manager=${manager%-query} 242 | 243 | ## UPTIME DETECTION 244 | 245 | if [ $distrotype = android ]; then 246 | uptime="$(uptime -p | cut -c 4-)" 247 | elif [ $distrotype = bsd ] || [ $distrotype = netbsd ]; then 248 | uptime="$(uptime | sed -e 's/.* up //; s/, [0-9]* user.*//')" 249 | else 250 | case $ostype in 251 | *"Linux"*) 252 | IFS=. read -r s _ ${c0}| ${lc}${ki} ${ic}${kernel}${reset} 366 | ${c0} /${c1}/ \\ ${c0}\\ ${lc}${ri} ${ic}${RAM}${memstat} ${mempercent} 367 | ${c0} ( ${c1}| | ${c0}/| ${lc}${pi} ${ic}${packages} (${manager})${reset} 368 | ${c2} _${c0}/\\ ${c1}__)${c0}/${c2}_${c0}) ${lc}${ui} ${ic}${uptime}${reset} 369 | ${c2} \/${c0}-____${c2}\/${reset} ${lc}${ci} ${red}███${green}███${yellow}███${blue}███${magenta}███${cyan}███${reset} 370 | EOF 371 | --------------------------------------------------------------------------------