File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments