-
Notifications
You must be signed in to change notification settings - Fork 8
/
gfetch.rc
executable file
·80 lines (72 loc) · 1.69 KB
/
gfetch.rc
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
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/rc
# Warning, parts of this script have been STOLEN!
# TODO:
# fs usage
# kernel
fn storage {
disks = `{ls -d /dev/sd* | uniq}
anydisk = 'false'
for(i in $disks){
if(test -f $i/data){
full = `{ls -l $i/data}
disk = `{echo $full | awk -F '/' '{print $3}'}
size = `{echo $full | awk '{print $6}'}
echo $disk^': '^`{echo $size^' / 1024 / 1024 /1024' | bc}^GB
anydisk = 'true'
}
}
if(~ $anydisk -c 'false')
echo Running in the diskless
}
fn fs {
if(ls /srv | grep -s '*.cmd')
ls /srv/*.cmd | sed 's/.cmd//g' | sed 's/\/srv\///g'
if(test -f /srv/fscons)
echo fossil
# Logic from storage to scrape for venti arenas
v='false'
disks = `{ls -d /dev/sd* | uniq}
for(i in $disks){
if(ls $i | grep -s arena)
v='true'
}
if(~ $v -c 'true')
echo venti
}
fn cpuid {
if(test -f /bin/aux/cpuid)
aux/cpuid >[2]/dev/null | grep procname | sed 's/.*procname//'
}
os=`{
if(grep -s 'zrv' /dev/drivers)
echo 9ants
if not if(grep -s 'vmx' /dev/drivers)
echo 9front
if not
echo Bell Labs
}
# fs and storage require #S bound on /dev
bind -b '#S' /dev
arch=`{echo $cputype}
shell=/bin/rc
uptime=`{uptime| sed 's/.*up//; s/..........$//'}
if(test -f /dev/screen) scr=`{dd -count 1 < /dev/screen|[2];}
scr=($scr(4) x $scr(5))
ram=(`{tr / ' '</dev/swap})
free=`{echo $ram(1)'/1024^2'|bc}
used=`{echo '('$ram(3)'*('$ram(7)^+$ram(5)^'))/1024^2'|bc}
cpu=`{cpuid}
files=`{fs}
strg=`{storage}
cat <<EOF
$user@$sysname
(\(\ -----------
j". .. os: Plan 9 from $os/$arch
( . .) shell: $shell
| ° ¡ uptime: $uptime
¿ ; ram: $used/$free MiB
c?".UJ cpu: $cputype $cpu
resolution: $scr
fs: $files
$strg
EOF