diff options
author | Ian Moffett <ian@osmora.org> | 2025-08-06 23:07:51 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-08-06 23:07:51 -0400 |
commit | 41a0b134379df327f94cb7cfe51789bcd339ee27 (patch) | |
tree | d6305bff5d5d71505b9d0eb833a2dd41e9a8c2ab /usr.bin/osh | |
parent | 88713baadfbc4ac78c5eccc546ecab3d145e12fb (diff) |
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 <ian@osmora.org>
Diffstat (limited to 'usr.bin/osh')
-rw-r--r-- | usr.bin/osh/osh.c | 6 |
1 files changed, 4 insertions, 2 deletions
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') { |