System/Core/Shell: Set window title in @shell_input_loop()

This commit is contained in:
Alec Murphy
2025-09-19 13:20:05 -04:00
parent 5f217c23f3
commit 8c39ffa94d

View File

@@ -225,6 +225,24 @@ U0 @shell_update_prompts(@shell* sh)
&sh->session->hostname, &buf);
}
U0 @shell_set_window_title(@shell* sh)
{
U8 buf[512];
U8 buf2[512];
U8 buf3[512];
StrCpy(&buf, &sh->cwd);
StrPrint(buf2, "/home/%s", &sh->session->user.name);
if (!StrCmp(&buf, &buf2))
StrCpy(&buf, "~");
else
StrCpy(&buf, StrLastOcc(&buf, "/") + 1);
StrPrint(buf3, "[%s@%s %s]", &sh->session->user.name,
&sh->session->hostname, &buf);
Stdio.WriteLine(sh, "\x1b]0;");
Stdio.WriteLine(sh, &buf3);
Stdio.WriteLine(sh, "\x07");
}
I64 @shell_input_loop(@shell* sh)
{
CHashFun* cmd;
@@ -238,6 +256,7 @@ I64 @shell_input_loop(@shell* sh)
while (!exit) {
@shell_update_prompts(sh);
@shell_set_window_title(sh);
Stdio.ReadLine(sh, sh->PS1, buf);
@shell_history_append(sh, &buf);