From 41a0b134379df327f94cb7cfe51789bcd339ee27 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 6 Aug 2025 23:07:51 -0400 Subject: usr.bin: osh: Add true hostname to prompt This commit puts the true hostname of the machine in the OSH prompt using gethostname() Signed-off-by: Ian Moffett --- usr.bin/osh/osh.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr.bin/osh') diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index 545f95a..5062e64 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -67,7 +67,7 @@ "clear - Clear the screen\n" \ "exit - Exit the shell" -#define PROMPT "[%s::osmora]~ " +#define PROMPT "[%s::%s]~ " static char last_command[INPUT_SIZE]; static char buf[INPUT_SIZE]; @@ -466,6 +466,7 @@ main(int argc, char **argv) { int found, prog_argc; int stdout_fd; + char hostname[128] = "osmora"; uint8_t buf_i; char *p; char c; @@ -478,9 +479,10 @@ main(int argc, char **argv) running = 1; bell_fd = open("/dev/beep", O_WRONLY); dump_file("/etc/motd"); + gethostname(hostname, sizeof(hostname)); while (running) { - printf(PROMPT, getlogin()); + printf(PROMPT, getlogin(), hostname); buf_i = getstr(); if (buf[0] == '\0') { -- cgit v1.2.3