Last active
April 16, 2016 22:12
-
-
Save kdbdallas/12105eefa4081d12571c to your computer and use it in GitHub Desktop.
A "Graphical" Welcome Message With Lots of Handy Info. Put It In The Bottom Of Your .bashrc
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
function welcome_msg() { | |
local upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)" | |
local secs=$((upSeconds%60)) | |
local mins=$((upSeconds/60%60)) | |
local hours=$((upSeconds/3600%24)) | |
local days=$((upSeconds/86400)) | |
local UPTIME=$(printf "%d days, %02dh%02dm%02ds" "$days" "$hours" "$mins" "$secs") | |
# calculate rough CPU and GPU temperatures: | |
local cpuTempC | |
local cpuTempF | |
local gpuTempC | |
local gpuTempF | |
if [[ -f "/sys/class/thermal/thermal_zone0/temp" ]]; then | |
cpuTempC=$(($(cat /sys/class/thermal/thermal_zone0/temp)/1000)) && cpuTempF=$((cpuTempC*9/5+32)) | |
fi | |
if [[ -f "/opt/vc/bin/vcgencmd" ]]; then | |
if gpuTempC=$(/opt/vc/bin/vcgencmd measure_temp); then | |
gpuTempC=${gpuTempC:5:2} | |
gpuTempF=$((gpuTempC*9/5+32)) | |
else | |
gpuTempC="" | |
fi | |
fi | |
local df_out=() | |
local line | |
while read line; do | |
df_out+=("$line") | |
done < <(df -h) | |
# get the load averages | |
read one five fifteen rest < /proc/loadavg | |
echo "$(tput setaf 2) | |
.~~. .~~. $(date +"%A, %e %B %Y, %r") | |
'. \ ' ' / .' $(uname -srmo)$(tput setaf 1) | |
.~ .~~~..~. | |
: .~.'~'.~. : $(tput setaf 3)${df_out[0]}$(tput setaf 1) | |
~ ( ) ( ) ~ $(tput setaf 7)${df_out[1]}$(tput setaf 1) | |
( : '~'.~.'~' : ) $(tput setaf 7)${df_out[7]}$(tput setaf 1) | |
~ .~ ~. ~ $(tput setaf 1)Uptime.............: ${UPTIME} | |
( $(tput setaf 4) | | $(tput setaf 7) ) $(tput setaf 1) Memory.............: $(grep MemFree /proc/meminfo | awk {'print $2'})kB (Free) / $(grep MemTotal /proc/meminfo | awk {'print $2'})kB (Total)$ | |
'~ ~' $(tput setaf 1) Load Averages......: ${one}, ${five}, ${fifteen} (1, 5, 15 min)$(tput setaf 7) | |
*--~-~--* $(tput setaf 1) Running Processes..: $(ps ax | wc -l | tr -d " ")$(tput setaf 7) | |
$(tput setaf 1) IP Address.........: $(ip route get 8.8.8.8 2>/dev/null | head -1 | cut -d' ' -f8) $(tput setaf 7) | |
$(tput setaf 1) Temperature........: CPU: $cpuTempC°C/$cpuTempF°F GPU: $gpuTempC°C/$gpuTempF°F | |
$(tput sgr0)" | |
} | |
welcome_msg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment