From c24be1ef0baef7734f6fdefda3c0cf44f534ce9c Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 13 Jun 2025 21:12:26 -0400 Subject: usr.bin: osh: Add builtin 'clear' command - Clear the screen with the "\033[H" ANSI escape sequence - Add clear command to the builtin command list Signed-off-by: Ian Moffett --- usr.bin/osh/osh.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'usr.bin/osh/osh.c') diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index aaa4502..db8865d 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -56,6 +56,7 @@ "kfg - Start up kfgwm\n" \ "bell - Toggle backspace bell\n" \ "time - Get the current time\n" \ + "clear - Clear the screen\n" \ "exit - Exit the shell" #define PROMPT "[root::osmora]~ " @@ -105,6 +106,12 @@ cmd_echo(int argc, char *argv[]) putchar('\n'); } +static void +cmd_clear(int argc, char *argv[]) +{ + fputs("\033[H", stdout); +} + static void cmd_bell(int argc, char *argv[]) { @@ -243,6 +250,7 @@ struct builtin_cmd cmds[] = { {"reboot",cmd_reboot}, {"shutdown", cmd_shutdown}, {"bell", cmd_bell}, + {"clear", cmd_clear}, {NULL, NULL} }; -- cgit v1.2.3