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);