commit ce5c3a6daca1b1992aca8cf7ffdcaf2167438a39 from: smytht via: GitHub date: Mon Jun 24 10:31:46 2024 UTC Merge pull request #148 from yellowman/smytht-clear-command-add add clear command to clear terminal screen (feedback from BSDCAN) tra… Ok by Stsp and leaving clear.1 manual page absence is resolved in current and by right should have been in previous releases commit - efd37145daca2646b4ed8c8d1c3eb319000c95df commit + ce5c3a6daca1b1992aca8cf7ffdcaf2167438a39 blob - 91052140f45e6788eee780c027ce39cee18ffc71 blob + 195d19e4a8cfe916e13bb8a6ee923a655cad9372 --- commands.c +++ commands.c @@ -76,6 +76,7 @@ struct intlist *whichlist; pid_t child; static int disable(void); +static int clear(void); static int doverbose(int, char**); static int doediting(int, char**); static int doconfig(int, char**); @@ -124,6 +125,7 @@ static int int_doverbose(char *, int, int, char **); static int int_doediting(char *, int, int, char **); static int int_manual(char *, int, int, char **); static int int_shell(char *, int, int, char **); +static int int_clear(void); static int int_help(void); static int int_exit(void); static int hostname(int, char **); @@ -1694,6 +1696,7 @@ static char rtablehelp[] = "Routing table switch", grouphelp[] = "Modify group attributes", arphelp[] = "Static ARP set", + clearhelp[]= "Clear the terminal screen", #ifdef notyet parphelp[] = "Proxy ARP set", #endif @@ -1813,6 +1816,7 @@ Command cmdtab[] = { { "pipex", pipexhelp, CMPL(ta) (char **)pipextab, sizeof(Menu), ipcmd, 1, 1, 1, 0 }, { "flush", flushhelp, CMPL(ta) (char **)flushlist, sizeof(Menu), flushcmd, 1, 0, 0, 0 }, { "enable", enablehelp, CMPL(ta) (char **)enabletab, sizeof(Menu), enable, 0, 0, 0, 0 }, + { "clear", clearhelp, CMPL0 0, 0, clear, 0, 0, 0, 0 }, { "disable", disablehelp, CMPL0 0, 0, disable, 1, 0, 0, 0 }, { "route", routehelp, CMPL0 0, 0, route, 1, 1, 1, 0 }, { "pf", pfhelp, CMPL(t) (char **)ctl_pf, ssctl, ctlhandler, 1, 1, 0, 1 }, @@ -2659,6 +2663,14 @@ group(int argc, char **argv) return 0; } +//clear terminal screen +int +clear(void) +{ + char *argv[] = {CLEAR, NULL, NULL }; + cmdargs(CLEAR, argv); + return 0; +} /* * disable privileged mode */ blob - 2e4977cfe088faa4a96086ab42f1262d2a78f9c1 blob + 6ec08fed8e002091820e76413562211332b40654 --- externs.h +++ externs.h @@ -174,6 +174,7 @@ extern pid_t child; #define DEFAULT_EDITOR "/usr/bin/vi" #define NSHRC_TEMP "/var/run/nshrc" #define NSHRC "/etc/nshrc" +#define CLEAR "/usr/bin/clear" #define PING "/sbin/ping" #define PING6 "/sbin/ping6" #define TRACERT "/usr/sbin/traceroute" blob - eef6496ff45a00493920b48445d4ad089a9ab9a3 blob + edba70f81791519f1fd06bb438b693c6a6943639 --- nsh.8 +++ nsh.8 @@ -174,19 +174,16 @@ is not ambiguous double completes the command. E.g show all available valid commands with double tab key sequence .Bd -literal -offset indent nsh(config-p)/ -! exit ipsec ping smtp -? flush ldap ping6 snmp -arp ftp-proxy ldp pipex ssh -bgp group motd quit sshd -bridge halt mpls rad telnet -configure help nameserver reboot tftp -ddb hostname ndp relay tftp-proxy -dhcp ifstate no resolv traceroute -disable ike nppp rip traceroute6 -dvmrp inet ntp route verbose -editing interface ospf rtable who -eigrp ip ospf6 sasync write-config -enable ip6 pf show +! disable halt ldap ospf relay smtp verbose +? do help ldp ospf6 resolv snmp who +arp dvmrp hostname manual pf rip ssh write-config +bgp editing ifstate motd ping route sshd +bridge eigrp ike mpls ping6 rtable telnet +clear enable inet nameserver pipex sasync tftp +configure exit interface ndp powerdown saveenv tftp-proxy +crontab flush ip no quit scheduler traceroute +ddb ftp-proxy ip6 nppp rad setenv traceroute6 +dhcp group ipsec ntp reboot show unsetenv nsh(config-p)/ .Ed If what is typed is ambiguous double tab presents the administrator @@ -358,6 +355,7 @@ nsh(p)/help pipex Set PIPEX parameters flush Flush system tables enable Enable privileged mode + clear Clear the terminal screen disable Disable privileged mode route Add a host or network route pf Packet filter control @@ -480,6 +478,16 @@ diagnostics in an unprivileged .Nm shell. .Pp +.Tg clear +.Ic clear +.Pp +Wipe contents of terminal and scrollback buffer and present a +.Nm +prompt at the first line of the active terminal. +See also +.Xr clear 1 +for more information. +.Pp .Tg rtable .Tg rdomain .Op no @@ -1368,7 +1376,7 @@ daemon can be edited with command, the configuration syntax of .Ic snmp daemon is documented in -.Xr snmpd.conf 5 +.Xr snmpd.conf 5 .Pp .Tg ldapd .Tg ldap