dotfiles/Executables/sys

46 lines
797 B
Bash
Executable file

#!/bin/sh
display() {
tput setaf 3
echo -n $1
echo -n " "
tput setaf 5
echo $2
}
field() {
num=$1
shift
echo $@ | cut -d ' ' -f $num
}
show_colors() {
for i in $(seq $1 $2)
do
tput setab $i
echo -n " "
done
tput setab reset
echo
}
display " " "$HOSTNAME"
display " " "$(uname -sr)"
display " " "$(yay -Qq | wc -l)"
diskinfo=$(df -h / | tail -n 1)
useddisk=$(field 3 $diskinfo)
totaldisk=$(field 2 $diskinfo)
display " " "${useddisk::-1}/${totaldisk::-1} GB ($(field 5 $diskinfo))"
raminfo=$(free --mega | head -n 2 | tail -n 1)
usedram=$(field 3 $raminfo)
totalram=$(field 2 $raminfo)
display " " "$usedram/$totalram MB ($(($usedram*100/$totalram))%)"
tput setaf reset
show_colors 0 7
show_colors 8 15