From a8311ab86cef575fc347b92f146185d30d46f8ed Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 17 Jul 2016 00:42:30 +0300 Subject: [PATCH] upysh: Add "clear" command to clear screen. Based on patch by @robert-hh: https://github.com/micropython/micropython-lib/pull/76 . --- upysh/upysh.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/upysh/upysh.py b/upysh/upysh.py index 4832365d..d9324659 100644 --- a/upysh/upysh.py +++ b/upysh/upysh.py @@ -25,8 +25,17 @@ class PWD: def __call__(self): return self.__repr__() +class CLEAR: + def __repr__(self): + return "\x1b[2J\x1b[H" + + def __call__(self): + return self.__repr__() + + pwd = PWD() ls = LS() +clear = CLEAR() cd = os.chdir mkdir = os.mkdir @@ -66,7 +75,8 @@ To see this help text again, type "man". upysh commands: pwd, cd("new_dir"), ls, ls(...), head(...), cat(...) -newfile(...), rm(...), mkdir(...), rmdir(...) +newfile(...), rm(...), mkdir(...), rmdir(...), +clear """) man = Man()