summaryrefslogtreecommitdiff
path: root/bin/common/saf
blob: 2936346691943a16b5d83d71003bb04278eb75fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh

# Simple Ass Fetch by futxlii

red="$(printf '\033[31m')"
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
done

KERNEL="$(uname -r)"
UPTIME="$(uptime -p)"; UPTIME="${UPTIME##up }"
SHELL="$(basename "$SHELL")"

cat <<EOF
	${red}- ${blue}${ID:-"unknown"}
	${red}- ${blue}$KERNEL
	${red}- ${blue}$UPTIME ($(load))
	${red}- ${blue}$SHELL${reset}
EOF