summaryrefslogtreecommitdiff
path: root/bin/common/saf
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-30 08:23:45 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-30 08:23:45 +0200
commit3f8594ee04d2a3d9b40a259daf3b564a53b510fa (patch)
tree66ed50643cdc81af813b5771a99732d0f78bb618 /bin/common/saf
parent45d39ae0c67bb086f4df0c366b251e06c888408d (diff)
parent333aaf38c66a1e4ba41d3acea38b21613c0075b2 (diff)
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/common/saf')
-rwxr-xr-xbin/common/saf13
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/common/saf b/bin/common/saf
index 0c6fbc4..2936346 100755
--- a/bin/common/saf
+++ b/bin/common/saf
@@ -3,10 +3,19 @@
# Simple Ass Fetch by futxlii
red="$(printf '\033[31m')"
-green="$(printf '\033[32m')"
blue="$(printf '\033[34m')"
reset="$(printf '\033[0m')"
+load ()
+{
+ # take everything after 'load average: ' then remove '0.' or '.' or ','
+ # from output, this multiplies by hundred, so we can divide an integer
+ # instead of a fraction (which dash can't do)
+ for time in $(uptime | sed -e 's/^.*load average://' -e 's/0\?\.\|,//g')
+ do printf "%s%%\n" "$((time/$(nproc)))"
+ done | xargs
+}
+
for file in /etc/os-release /usr/lib/os-release
do
[ -f "$file" ] && . "$file" && break
@@ -19,6 +28,6 @@ SHELL="$(basename "$SHELL")"
cat <<EOF
${red}- ${blue}${ID:-"unknown"}
${red}- ${blue}$KERNEL
- ${red}- ${blue}$UPTIME
+ ${red}- ${blue}$UPTIME ($(load))
${red}- ${blue}$SHELL${reset}
EOF