forked from jschx/ufetch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ufetch-linux
executable file
·67 lines (49 loc) · 1.75 KB
/
ufetch-linux
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#
# ufetch-linux - tiny system info for linux
## INFO
# user is already defined
host="$(cat /proc/sys/kernel/hostname)"
os="$(uname -o)"
kernel="$(uname -srm)"
#Read uptime
IFS=. read -r s _ < /proc/uptime
# Convert the uptime from seconds into days, hours and minutes.
d=$((s / 60 / 60 / 24))
h=$((s / 60 / 60 % 24))
m=$((s / 60 % 60))
# Only append days, hours and minutes if they're non-zero.
[ "$d" = 0 ] || uptime="${uptime}${d}d "
[ "$h" = 0 ] || uptime="${uptime}${h}h "
[ "$m" = 0 ] || uptime="${uptime}${m}m "
uptime="${uptime:-0m}"
shell="$(basename "$SHELL")"
# Get CPU name.
cpu_file="/proc/cpuinfo"
cpu="$(awk -F '\\s*: | @' \
'/model name|Hardware|Processor|^system type|chip type|^cpu type/ {
cpu=$2; if ($1 == "Hardware") exit } END { print cpu }' "$cpu_file")"
## DEFINE COLORS
# probably don't change these
bold='[1m'
reset='[0m'
# you can change these
lc="${reset}${bold}" # labels
nc="${reset}${bold}" # user and hostname
ic="${reset}" # info
c0='[39m'
c1='[31m'; c2='[32m'
c3='[33m'; c4='[34m'
c5='[35m'; c6='[36m'
c7='[37m'; c8='[38m'
palette="[7m$c1 $c2 $c3 $c4 $c5 $c6 $c7 "
## OUTPUT
cat <<EOF
${bold}${c0} ___ ${nc}${USER}${ic}@${nc}${host}${reset}
${bold}${c0} (${c7}.. ${c0}\ ${lc}OS: ${ic}${os}${reset}
${bold}${c0} (${c3}<> ${c0}| ${lc}CPU: ${ic}${cpu}${reset}
${bold}${c0} /${c7}/ \\ ${c0}\\ ${lc}KERNEL: ${ic}${kernel}${reset}
${bold}${c0} ( ${c7}| | ${c0}/| ${lc}UPTIME: ${ic}${uptime}${reset}
${bold}${c3} _${c0}/\\ ${c7}__)${c0}/${c3}_${c0}) ${lc}SHELL: ${ic}${shell}${reset}
${bold}${c3} \/${c0}-____${c3}\/${reset} ${ic}${palette}${reset}
EOF