Dotfiles config update (2022-04-15)

This commit is contained in:
q3aql 2022-04-15 20:20:42 +02:00
parent a6fe57c271
commit 0f123081fd
3 changed files with 58 additions and 9 deletions

23
.bashrc
View File

@ -160,11 +160,28 @@ else
os_system=$(echo ${os_system}) os_system=$(echo ${os_system})
fi fi
kernel=$(uname -r) kernel=$(uname -r)
uptime=$(uptime 2> /dev/null | tr -s " " | cut -d "," -f 1) if [ -f /proc/uptime ] ; then
if [ -z "${uptime}" ] ; then uptime_sec=$(cat /proc/uptime)
uptime="Unknown" uptime_sec_cut=$(echo ${uptime_sec} | tr -s " " | cut -d " " -f 1 | cut -d "." -f 1)
uptime_min=$(expr ${uptime_sec_cut} / 60)
if [ ${uptime_min} -le 59 ] ; then
uptime="${uptime_min}min"
else
uptime_hour=$(expr ${uptime_min} / 60)
if [ ${uptime_hour} -le 23 ] ; then
uptime="${uptime_hour}h"
else
uptime_day=$(expr ${uptime_hour} / 24)
uptime="${uptime_day}d"
fi
fi
else else
uptime=$(uptime 2> /dev/null | tr -s " " | cut -d "," -f 1)
if [ -z "${uptime}" ] ; then
uptime="Unknown"
else
uptime=$(echo ${uptime}) uptime=$(echo ${uptime})
fi
fi fi
#shell="5.1.4" # Run bash --version #shell="5.1.4" # Run bash --version
shell=$(bash --version | head -1 | tr -s " " | cut -d " " -f 4 | cut -d "(" -f 1 | cut -d "-" -f 1) shell=$(bash --version | head -1 | tr -s " " | cut -d " " -f 4 | cut -d "(" -f 1 | cut -d "-" -f 1)

View File

@ -28,7 +28,22 @@ else
set os_system (uname -o) set os_system (uname -o)
end end
set kernel (uname -r) set kernel (uname -r)
if test -f /usr/bin/uptime if test -f /proc/uptime
set uptime_sec (cat /proc/uptime)
set uptime_sec_cut (echo $uptime_sec | tr -s " " | cut -d " " -f 1 | cut -d "." -f 1)
set uptime_min (expr $uptime_sec_cut / 60)
if test "$uptime_min" -le "59"
set uptime {$uptime_min}min
else
set uptime_hour (expr $uptime_min / 60)
if test "$uptime_hour" -le "23"
set uptime {$uptime_hour}h
else
set uptime_day (expr $uptime_hour / 24)
set uptime {$uptime_day}d
end
end
else if test -f /usr/bin/uptime
set uptime (uptime | tr -s " " | cut -d "," -f 1) set uptime (uptime | tr -s " " | cut -d "," -f 1)
set uptime (echo {$uptime} | cut -f 2) set uptime (echo {$uptime} | cut -f 2)
else else

23
.zshrc
View File

@ -252,11 +252,28 @@ echo ""
echo -e -n "\e[32m# Preparing to start \e[0m\e[35mzsh\e[0m \e[32mshell...\e[0m" echo -e -n "\e[32m# Preparing to start \e[0m\e[35mzsh\e[0m \e[32mshell...\e[0m"
os_system=$(uname -o) os_system=$(uname -o)
kernel=$(uname -r) kernel=$(uname -r)
uptime=$(uptime 2> /dev/null | tr -s " " | cut -d "," -f 1) if [ -f /proc/uptime ] ; then
if [ -z "${uptime}" ] ; then uptime_sec=$(cat /proc/uptime)
uptime="Unknown" uptime_sec_cut=$(echo ${uptime_sec} | tr -s " " | cut -d " " -f 1 | cut -d "." -f 1)
uptime_min=$(expr ${uptime_sec_cut} / 60)
if [ ${uptime_min} -le 59 ] ; then
uptime="${uptime_min}min"
else
uptime_hour=$(expr ${uptime_min} / 60)
if [ ${uptime_hour} -le 23 ] ; then
uptime="${uptime_hour}h"
else
uptime_day=$(expr ${uptime_hour} / 24)
uptime="${uptime_day}d"
fi
fi
else else
uptime=$(uptime 2> /dev/null | tr -s " " | cut -d "," -f 1)
if [ -z "${uptime}" ] ; then
uptime="Unknown"
else
uptime=$(echo ${uptime}) uptime=$(echo ${uptime})
fi
fi fi
#shell="5.8" # Run zsh --version #shell="5.8" # Run zsh --version
shell=$(zsh --version | cut -d " " -f 2) shell=$(zsh --version | cut -d " " -f 2)