-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjanet.janet
More file actions
25 lines (22 loc) · 833 Bytes
/
janet.janet
File metadata and controls
25 lines (22 loc) · 833 Bytes
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
(let [user (os/getenv "USER")
host (slurp "/etc/hostname")
kernel (->> (slurp "/proc/version") (string/split " ") 2)
term (os/getenv "TERM")
shell (os/getenv "SHELL")
tasks (length (filter scan-number (os/dir "/proc")))
mem (->> (slurp "/proc/meminfo") (string/split "\n") (take 3))
uptime (->> (slurp "/proc/uptime") (string/split ".") 0 int/u64)]
(defn split [s] (filter (comp not empty?) (string/split " " s)))
(def mem (map (comp |(/ $ 1000) int/u64 1 split) mem))
(def total (mem 0))
(def avail (mem 2))
(def d (-> uptime (/ 60 60 24)))
(def h (-> uptime (/ 60 60) (% 24)))
(def m (-> uptime (/ 60) (% 60)))
(print user "@" host
"kernel\t" kernel
"\nterm\t" term
"\nshell\t" shell
"\ntasks\t" tasks
"\nmem\t" avail "m / " total "m"
"\nuptime\t" d "d " h "h " m "m"))