fetch

MSYS2-compatible system info prompt
git clone https://git.torresjrjr.com/fetch.git
Log | Files | Refs | README | LICENSE

commit 28e45da662f3bb086e77cce9fb6b6923b7a10000
parent b735e08dd90b4bce25f64a16a7a0dd76eeb57ffe
Author: Byron Torres <b@torresjrjr.com>
Date:   Mon, 21 Feb 2022 17:02:41 +0000

Redundancy for _uptime() with uptime utility

Diffstat:
Mfetch | 10+++++++---
1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fetch b/fetch @@ -50,9 +50,13 @@ _os() { env printf "$1" "$(uname -o) $(uname -r)" } _uptime() { - s=$(cat /proc/uptime) s=${s%%.*} - days=$(($s / 86400)) mins=$(($s / 3600 % 24)) hours=$(($s / 60 % 60)) - env printf "$1" "${days}d ${mins}m ${hours}h (${s}s)" + [ -r /proc/uptime ] && { + s=$(cat /proc/uptime) s=${s%%.*} + days=$(($s / 86400)) mins=$(($s / 3600 % 24)) hours=$(($s / 60 % 60)) + env printf "$1" "${days}d ${mins}m ${hours}h (${s}s)" + } || { + env printf "$1" "$(uptime --pretty 2>&- || uptime)" + } } _shell() { env printf "$1" "$(readlink /proc/$PPID/exe)"