Give the shell a nice, colorful prompt.
The cwd looks like crap, I need to write some code to strip out ".." and extra slashes from the path string.
This commit is contained in:
parent
dd3244137e
commit
52c19136f2
Notes:
sideshowbarker
2024-07-19 18:37:22 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/52c19136f2f
1 changed files with 6 additions and 1 deletions
|
@ -6,13 +6,14 @@
|
|||
#include <LibC/stdlib.h>
|
||||
|
||||
char* g_cwd = nullptr;
|
||||
char g_hostname[32];
|
||||
|
||||
static void prompt()
|
||||
{
|
||||
if (getuid() == 0)
|
||||
printf("# ");
|
||||
else
|
||||
printf("$ ");
|
||||
printf("\033[32;1m%s\033[0m:\033[34;1m%s\033[0m$> ", g_hostname, g_cwd);
|
||||
}
|
||||
|
||||
static int sh_pwd(int, const char**)
|
||||
|
@ -114,6 +115,10 @@ static int runcmd(char* cmd)
|
|||
|
||||
int main(int, char**)
|
||||
{
|
||||
int rc = gethostname(g_hostname, sizeof(g_hostname));
|
||||
if (rc < 0)
|
||||
perror("gethostname");
|
||||
|
||||
char linebuf[128];
|
||||
int linedx = 0;
|
||||
linebuf[0] = '\0';
|
||||
|
|
Loading…
Add table
Reference in a new issue