#!/bin/sh # btfetch 0.15 -- LostGeek.NET == Jul 19, 2025 # bens tiny fetch -- Distro-aware, supports: Debian, Ubuntu, Fedora, Arch, Alpine, Void, etc. # Setup host="$(hostname)" kernel="$(uname -sr)" uptime_output=$(uptime) # Detect OS and count packages if [ -f /etc/os-release ]; then . /etc/os-release os="${PRETTY_NAME}" else os="$(uname -o)" fi # Package count by distro if command -v dpkg >/dev/null 2>&1; then packages="$(dpkg -l | grep -c ^i)" elif command -v rpm >/dev/null 2>&1; then packages="$(rpm -qa | wc -l)" elif command -v pacman >/dev/null 2>&1; then packages="$(pacman -Qq | wc -l)" elif command -v apk >/dev/null 2>&1; then packages="$(apk info | wc -l)" elif command -v xbps-query >/dev/null 2>&1; then packages="$(xbps-query -l | wc -l)" else packages="unknown" fi # Extract days up if echo "$uptime_output" | grep -q 'day'; then daysup=$(echo "$uptime_output" | awk -F'up ' '{print $2}' | awk '{print $1}' | sed 's/[^0-9]*//g') else daysup=0 fi # Users and load average users=$(echo "$uptime_output" | awk -F'users?, ' '{print $1}' | awk '{print $NF}' | sed 's/[^0-9]*//g') loadavg=$(echo "$uptime_output" | awk -F'load average: ' '{print $2}' | sed 's/,/ /g') # CPU rawcpus="$(echo "$(nproc) x $(model=$(grep "model name" /proc/cpuinfo | head -n1 | cut -d ":" -f2 | sed 's/^[ \t]*//'); if [ -n "$model" ]; then echo "$model"; else echo "$(lscpu | grep "Vendor ID" | cut -d ":" -f2 | sed 's/^[ \t]*//') $(lscpu | grep "Model name" | cut -d ":" -f2 | sed 's/^[ \t]*//')"; fi)")" precpus=$(echo "$rawcpus" | sed -E 's/\(R\)|\(TM\)|CPU//g' | sed 's/[[:space:]]+/ /g' | sed 's/^ //;s/ $//' | sed 's/ @.*//' | sed 's/ / /g' | sed 's/ / /g') # CPU frequency if [ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq ]; then cpu_freq=$(awk '{if ($1 < 1000000) printf "%.0f MHz", $1/1000; else printf "%.2f GHz", $1/1000000}' /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) else cpu_freq="unknown" fi cpus="$precpus ($cpu_freq)" # Memory freeth=$(free -h | grep Mem) usedmem=$(echo "$freeth" | awk '{print $3}') totalmem=$(echo "$freeth" | awk '{print $2}') # Colors if [ -x "$(command -v tput)" ]; then bold="$(tput bold 2>/dev/null)" black="$(tput setaf 0 2>/dev/null)" red="$(tput setaf 1 2>/dev/null)" green="$(tput setaf 2 2>/dev/null)" yellow="$(tput setaf 3 2>/dev/null)" blue="$(tput setaf 4 2>/dev/null)" magenta="$(tput setaf 5 2>/dev/null)" cyan="$(tput setaf 6 2>/dev/null)" white="$(tput setaf 7 2>/dev/null)" reset="$(tput sgr0 2>/dev/null)" fi # Colors used in fetch lc="${reset}${bold}${red}" # labels nc="${reset}${bold}${red}" # username@hostname ic="${reset}" # values # Try to detect PS1 prompt color promptcolor=$(grep -oP '\\\[\\033\[[0-9;]+m\\\]' ~/.bashrc 2>/dev/null | head -n1 | sed 's/\\\[//g; s/\\\]//g') case "$promptcolor" in *32m*) c0="${reset}${green}" ;; *31m*) c0="${reset}${red}" ;; *33m*) c0="${reset}${yellow}" ;; *34m*) c0="${reset}${blue}" ;; *35m*) c0="${reset}${magenta}" ;; *36m*) c0="${reset}${cyan}" ;; *30m*) c0="${reset}${black}" ;; *) c0="${reset}" ;; esac # Output cat <