mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:47:35 +00:00
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
1 changed files with 6 additions and 1 deletions
|
@ -6,13 +6,14 @@
|
||||||
#include <LibC/stdlib.h>
|
#include <LibC/stdlib.h>
|
||||||
|
|
||||||
char* g_cwd = nullptr;
|
char* g_cwd = nullptr;
|
||||||
|
char g_hostname[32];
|
||||||
|
|
||||||
static void prompt()
|
static void prompt()
|
||||||
{
|
{
|
||||||
if (getuid() == 0)
|
if (getuid() == 0)
|
||||||
printf("# ");
|
printf("# ");
|
||||||
else
|
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**)
|
static int sh_pwd(int, const char**)
|
||||||
|
@ -114,6 +115,10 @@ static int runcmd(char* cmd)
|
||||||
|
|
||||||
int main(int, char**)
|
int main(int, char**)
|
||||||
{
|
{
|
||||||
|
int rc = gethostname(g_hostname, sizeof(g_hostname));
|
||||||
|
if (rc < 0)
|
||||||
|
perror("gethostname");
|
||||||
|
|
||||||
char linebuf[128];
|
char linebuf[128];
|
||||||
int linedx = 0;
|
int linedx = 0;
|
||||||
linebuf[0] = '\0';
|
linebuf[0] = '\0';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue