From b390e2764b9a77420ee15d0bf04c93a333c60cf4 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Thu, 3 Aug 2017 17:42:59 +1000 Subject: [PATCH] added some nice stuff like ps(*f*) and mem() to shutil --- modules/lib/shutil.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/lib/shutil.lua b/modules/lib/shutil.lua index 6584097..e561c85 100644 --- a/modules/lib/shutil.lua +++ b/modules/lib/shutil.lua @@ -9,3 +9,16 @@ function cat(p) print(f:read("*a")) f:close() end +function ps(f) + local f=f or "" + for k,v in ipairs(os.tasks()) do + if v:find(f) then + print(tostring(k).."\t"..tostring(v)) + end + end +end +function mem() + print("Total:\t"..tostring(math.floor(computer.totalMemory()/1024)).."K") + print("Free: \t"..tostring(math.floor(computer.freeMemory()/1024)).."K") + print("Used: \t"..tostring(math.floor((computer.totalMemory()-computer.freeMemory())/1024)).."K") +end