Skip to content

Instantly share code, notes, and snippets.

@mateoppalacios
Created July 29, 2021 09:18
Show Gist options
  • Save mateoppalacios/96ea576bdb483375ce50dfd639d1528f to your computer and use it in GitHub Desktop.
Save mateoppalacios/96ea576bdb483375ce50dfd639d1528f to your computer and use it in GitHub Desktop.
A tiny fetching utility for Linux.
#!/usr/bin/env bash
n=printf\ "\n"; i="${TF_INFO:=title os kernel host uptime memory shell colors}"
c="\e[1;${TF_COLOR-34}m"; r="\e[0m"; for o in $i; do case "$o" in title)
printf "${c}%s${r}@${c}%s\n" "$USER" "$HOSTNAME" ;; os) [ -f /etc/os-release ]\
&& { . /etc/os-release; printf "${c}OS${r}\t%s\n" "$NAME"; } ;; kernel)
printf "${c}Kernel${r}\t%s\n" "$(uname -r)" ;; host) printf \
"${c}Host${r}\t%s\n" "$HOSTNAME" ;; uptime) t="$(cat /proc/uptime)"; printf \
"${c}Uptime:${r}\t%s\n" "$(date -d@${t%% *} -u +%H:%M:%S)" ;; memory) printf \
"${c}Memory:${r}\t%s\n" "$(free -h | awk 'NR == 2 { printf("%s/%s\n", $3, $2) \
}')" ;; shell) printf "${c}Shell${r}\t%s\n" "${SHELL##*/}" ;; colors) $n; for \
i in {30..37} {90..97}; do printf "\e[${i}m${TF_COLORS_CHAR:=■}\e[0m"
((i == 37)) && $n; done ;; esac; done; $n; $n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment