BASH fetch?


BASH fetch?

I don't know why there are too many implementations that look like neofetch and why they are so complicated. I mean, i just saw one, using python and being tenths of files and hundreds lines of code. Why? Because of the ASCII logo?

Anyway... if you want a quick way to see a complete summary of system info, you can use inxi -b. Just that! If you don't have installed inxi, just sudo apt install inxi. That easy.

And if you don't want to install any other program/package, use the following script i made. It uses only BASH and Linux commands, no need to install anything. Feel free to customize it as you like.

Updated on 2025/01/10:

  • Added support for Raspberry Pi
#!/usr/bin/bash

C06="\e[0;33m"
CE="\e[0m"
C14="\e[1;33m"

function israspberry() {
  cat /proc/cpuinfo | grep -i "raspberry" &> /dev/null
}

function trim() {
  sed -e 's/^[[:space:]]*//'
}

function gpu() {
  GPU=$(lspci | grep VGA | cut -d ":" -f3);RAM=$(cardid=$(lspci | grep VGA |cut -d " " -f1);lspci -v -s $cardid | grep " prefetchable"| cut -d "=" -f2);echo $GPU $RAM
}

echo -e $C06"user          "$C14":"$CE" $(whoami)"
echo -e $C06"host          "$C14":"$CE" $(hostname)"
echo -e $C06"os            "$C14":"$CE" $(lsb_release -d | cut -f2 -d: | trim) $(lsb_release -c | cut -f2)"
echo -e $C06"kernel        "$C14":"$CE" $(uname -r)"
echo -e $C06"uptime        "$C14":"$CE" $(uptime -p)"
echo -e $C06"processes     "$C14":"$CE" $(ps -aux | sed 1n | wc -l)"
echo -e $C06"window manager"$C14":"$CE" $XDG_CURRENT_DESKTOP"
echo -e $C06"desktop       "$C14":"$CE" $DESKTOP_SESSION"
echo -e $C06"shell env.    "$C14":"$CE" $SHELL"
echo -e $C06"terminal app. "$C14":"$CE" $(ps -p $(ps -p $$ -o ppid=) -o args=)"
echo -e $C06"inst. packages"$C14":"$CE" dpkg: $(dpkg --get-selections | wc -l)"
israspberry
if [ $? -eq 0 ]; then
  echo -e $C06"cpu info      "$C14":"$CE" $(cat /proc/cpuinfo | grep -i "model" -m 1 | cut -d":" -f2 | trim)"
else
  echo -e $C06"cpu info      "$C14":"$CE" $(cat /proc/cpuinfo | grep -i "model name" -m 1 | cut -d":" -f2 | trim)"
  echo -e $C06"gpu info      "$C14":"$CE" $(gpu)"
fi
echo -e $C06"memory        "$C14":"$CE" $(free -h | grep Mem | awk '{print "used:"$3, "total:"$2,"free:"$4'})"
echo -e $C06"swap file     "$C14":"$CE" $(free -h | grep Swap | awk '{print "used:"$3, "total:"$2,"free:"$4'})"
echo -e $C06"internal ip   "$C14":"$CE" $(hostname -I | cut -f1 -d" ")"
echo -e $C06"external ip   "$C14":"$CE" $(curl ipinfo.io/ip -s)"

Add a comment

Previous Next