-
-
Save nerun/8dae408f6043e10bfbcf93a860d47136 to your computer and use it in GitHub Desktop.
Cabeçalho para o terminal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Include 'os-release' to grab Debian pretty name... | |
. /etc/os-release | |
# Styles... | |
red="\e[91m" | |
redbold="\e[1;91m" | |
magenta="\e[1;95m" | |
reset="\e[0m" | |
# Main | |
clear | |
# Uso de memória: usada / total (precentual de uso) | |
# Arquivo /proc/meminfo (campos MemTotal e MemAvailable). | |
mem_usage() { | |
awk ' | |
/MemTotal/ {mt = ($2/1024)} | |
/MemAvailable/ {ma = ($2/1024)} | |
END { | |
mu = mt - ma | |
mp = 100 * (mu / mt) | |
printf "%.0f MiB / %.0f MiB (%d%%)", mu, mt, mp | |
}' /proc/meminfo | |
} | |
print_cpu() { | |
# Modelo da CPU... | |
local model="$(grep -Pom1 'model name\s+: \K.*' /proc/cpuinfo)" | |
# Número de núcleos... | |
local cores=$(grep -c '^processor' /proc/cpuinfo) | |
# Frequência máxima... | |
local file=/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq | |
local maxfreq=$(awk '{printf "@ %.3fGHz", $0*10^-6}' $file) | |
echo "$model ($cores threads $maxfreq)" | |
} | |
board_vendor=$(cat /sys/devices/virtual/dmi/id/board_vendor | cut -d' ' -f1) | |
board_name=$(cat /sys/devices/virtual/dmi/id/board_name) | |
print_gpu(){ | |
if which glxinfo > /dev/null 2>&1; then | |
local board=$(glxinfo | grep Device | cut -d':' -f2- | sed -r 's/\(.*//g' | sed 's/^ *//;s/ *$//') | |
local vram=$(glxinfo | grep 'Video memory' | cut -d':' -f2- | sed 's/^ *//;s/ *$//') | |
gpu="$board ($vram)" | |
else | |
gpu=$(lspci | grep VGA | cut -d ":" -f3 | sed -r 's/.*\[(.*)\].*\[(.*)\].*/\1 \2/g') | |
if [ -z $gpu ]; then | |
gpu=$(lspci | grep VGA | cut -d ":" -f3 | sed -r 's/.*\[(.*)\].*/\1/g') | |
fi | |
fi | |
echo $gpu | |
} | |
echo -e " | |
$red ⢀⣴⠾⠻⢶⣦⠀ ${reset}${redbold}$PRETTY_NAME${reset} | |
$red ⣾⠁⢠⠒⠀⣿⡁ ${reset}${magenta}Kernel:${reset} $(uname -rm) | |
$red ⢿⡄⠘⠷⠚⠋⠀ ${reset}${magenta}Board: ${reset} $board_vendor $board_name | |
$red ⠈⠳⣄⠀⠀⠀⠀ ${reset}${magenta}CPU: ${reset} $(print_cpu) | |
${magenta}GPU: ${reset} $(print_gpu) | |
${magenta}RAM: ${reset} $(mem_usage) | |
${magenta}User: ${reset} $USER@$HOST | |
${magenta}Uptime:${reset} $(uptime -p | cut -d' ' -f2-) | |
${magenta}Shell: ${reset} $SHELL" | |
exit 0 |
Author
nerun
commented
Feb 5, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment