From 8c39ffa94d4276ab9cd95ac228a28f5f56474667 Mon Sep 17 00:00:00 2001 From: Alec Murphy Date: Fri, 19 Sep 2025 13:20:05 -0400 Subject: [PATCH] System/Core/Shell: Set window title in @shell_input_loop() --- System/Core/Shell.HC | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/System/Core/Shell.HC b/System/Core/Shell.HC index 533b5f9..613c4a5 100644 --- a/System/Core/Shell.HC +++ b/System/Core/Shell.HC @@ -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);