Skip to content

Instantly share code, notes, and snippets.

@mochaaP
Last active May 14, 2022 19:20
Show Gist options
  • Save mochaaP/322ba2316debab65fdbfa039fd855138 to your computer and use it in GitHub Desktop.
Save mochaaP/322ba2316debab65fdbfa039fd855138 to your computer and use it in GitHub Desktop.
a modified ufetch
#!/bin/sh
#
# ifetch-alpine - tiny system info for alpine
# modified from ufetch
## INFO
. /etc/os-release
host="$(hostname)"
ip="$(ip addr show dev eth0 | awk '/inet / {print $2}' | cut -d/ -f1)"
os="$(printf $VERSION_ID | awk -F"_alpha" '{if ($2 == "") print $1; else print $1" ("$2")"}')"
kernel="$(uname -r)"
uptime="$(uptime | awk -F, '{sub(".*up ",x,$1);print $1}' | sed -e 's/^[ \t]*//')"
packages="$(apk info | wc -l) (^$(apk -u list | wc -l))"
storage="$(df -h / | awk '/^\// {print $3 "/" $2 " (" $5 ")"}' | head -n1)"
memory="$(free -m | awk '/Mem:/ {printf "%d/%dM", $3, $2}')"
## DEFINE COLORS
bold='\033[1m'
black='\033[0;30m'
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
blue='\033[0;34m'
magenta='\033[0;35m'
cyan='\033[0;36m'
white='\033[0;37m'
reset='\033[0m'
# you can change these
lc="${reset}${bold}${blue}" # labels
nc="${reset}${cyan}" # hostname and ip
ic="${reset}" # info
c0="${reset}${blue}" # first color
## OUTPUT
echo -ne "
${c0} /\\ ${nc}${host}${ic} @ ${nc}${ip}${reset}
${c0} / \\ ${lc}version ${ic}${os}${reset}
${c0} / /\\ \\ /\\ ${lc}kernel ${ic}${kernel}${reset}
${c0} / / \\ \\/ \\ ${lc}uptime ${ic}${uptime}${reset}
${c0} / / \\ \\/\\ \\ ${lc}packages ${ic}${packages}${reset}
${c0} / / /| \\ \\ \\ \\ ${lc}storage ${ic}${storage}${reset}
${c0} /_/ /_| \\_\\ \\_\\ ${lc}memory ${ic}${memory}${reset}
"
@mochaaP
Copy link
Author

mochaaP commented Apr 12, 2022

demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment