summaryrefslogtreecommitdiff
path: root/usr.bin/osh/osh.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-06-13 21:12:26 -0400
committerIan Moffett <ian@osmora.org>2025-06-13 21:12:26 -0400
commitc24be1ef0baef7734f6fdefda3c0cf44f534ce9c (patch)
tree903dcbe7110697864f56204bd76ed4cf12df8ac2 /usr.bin/osh/osh.c
parent6996c3587cffb67baa0d2dd7c12e0a123ad29e10 (diff)
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 <ian@osmora.org>
Diffstat (limited to 'usr.bin/osh/osh.c')
-rw-r--r--usr.bin/osh/osh.c8
1 files changed, 8 insertions, 0 deletions
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]~ "
@@ -106,6 +107,12 @@ cmd_echo(int argc, char *argv[])
}
static void
+cmd_clear(int argc, char *argv[])
+{
+ fputs("\033[H", stdout);
+}
+
+static void
cmd_bell(int argc, char *argv[])
{
const char *usage_str = "usage: bell [on/off]";
@@ -243,6 +250,7 @@ struct builtin_cmd cmds[] = {
{"reboot",cmd_reboot},
{"shutdown", cmd_shutdown},
{"bell", cmd_bell},
+ {"clear", cmd_clear},
{NULL, NULL}
};