From e40955e9c69b48f3de65d56fad000381f78e7cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Harald=20J=C3=B8rgensen?= <58829763+adamjoer@users.noreply.github.com> Date: Tue, 24 Oct 2023 23:26:03 +0200 Subject: [PATCH] Shell: Add support for showing current time in prompt with "\{t|T|@}" --- Userland/Shell/Shell.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index 9cf981a2ed..a508660dfe 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -129,6 +130,15 @@ DeprecatedString Shell::prompt() const } else if (lexer.consume_specific('p')) { builder.append(uid == 0 ? '#' : '$'); + } else if (lexer.consume_specific('t')) { + builder.append(Core::DateTime::now().to_deprecated_string("%H:%M:%S"sv)); + + } else if (lexer.consume_specific('T')) { + builder.append(Core::DateTime::now().to_deprecated_string("%I:%M:%S"sv)); + + } else if (lexer.consume_specific('@')) { + builder.append(Core::DateTime::now().to_deprecated_string("%I:%M %p"sv)); + } else if (lexer.consume_specific('j')) { builder.appendff("{}", jobs.size());