We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 00526df commit abd1302Copy full SHA for abd1302
1 file changed
src/clear.py
@@ -0,0 +1,34 @@
1
+#!/usr/bin/python3
2
+
3
+import sys
4
+from optparse import OptionParser
5
6
+# clear(1), roughly modelled off the ncurses implementation.
7
8
9
+def clear(opts):
10
+ print("\x1b[2J\x1b[H", end="")
11
+ if not opts.x:
12
+ print("\x1b[3J", end="")
13
14
15
+if __name__ == "__main__":
16
+ parser = OptionParser(
17
+ usage="Usage: %prog [OPTION]...",
18
+ description="Clear the terminal screen.",
19
+ add_help_option=False,
20
+ )
21
+ parser.add_option("--help", action="help", help="show usage information and exit")
22
23
+ parser.add_option("-T", metavar="TERM", help="(unimplemented)")
24
25
+ parser.add_option(
26
+ "-x", action="store_true", help="do not try to clear the scrollback buffer"
27
28
29
+ opts, args = parser.parse_args()
30
31
+ if args:
32
+ sys.exit(1)
33
34
+ clear(opts)
0 commit comments