Snazz up the sh prompt a bit. Add the current tty to it.

This commit is contained in:
Andreas Kling 2018-10-31 01:21:56 +01:00
parent 3218f00099
commit 511ed4c4de
Notes: sideshowbarker 2024-07-19 18:36:01 +09:00
2 changed files with 6 additions and 10 deletions

View File

@ -40,12 +40,6 @@ VirtualConsole* tty2;
VirtualConsole* tty3;
Keyboard* keyboard;
void banner()
{
InterruptDisabler disabler;
kprintf("\n\033[33;1mWelcome to \033[36;1mSerenity OS!\033[0m\n\n");
}
static byte parseHexDigit(char nibble)
{
if (nibble >= '0' && nibble <= '9')
@ -191,8 +185,6 @@ static void init_stage2()
}
#endif
banner();
int error;
auto* sh0 = Task::createUserTask("/bin/sh", (uid_t)100, (gid_t)100, (pid_t)0, error, nullptr, tty0);
auto* sh1 = Task::createUserTask("/bin/sh", (uid_t)100, (gid_t)100, (pid_t)0, error, nullptr, tty1);

View File

@ -9,6 +9,7 @@
struct GlobalState {
String cwd;
char ttyname[32];
char hostname[32];
};
static GlobalState* g;
@ -18,7 +19,7 @@ static void prompt()
if (getuid() == 0)
printf("# ");
else
printf("(%u) \033[32;1m%s\033[0m:\033[34;1m%s\033[0m$> ", getpid(), g->hostname, g->cwd.characters());
printf("\033[31;1m%s\033[0m:\033[37;1m%s\033[0m:\033[32;1m%s\033[0m$> ", g->ttyname, g->hostname, g->cwd.characters());
}
static int sh_pwd(int, const char**)
@ -157,7 +158,7 @@ static void greeting()
perror("uname");
return;
}
printf("\n%s/%s on %s\n\n", uts.sysname, uts.machine, ttyname(0));
printf("\n%s/%s on %s\n\n", uts.sysname, uts.machine, g->ttyname);
}
int main(int, char**)
@ -166,6 +167,9 @@ int main(int, char**)
int rc = gethostname(g->hostname, sizeof(g->hostname));
if (rc < 0)
perror("gethostname");
rc = ttyname_r(0, g->ttyname, sizeof(g->ttyname));
if (rc < 0)
perror("ttyname_r");
greeting();