From 050c73d3012f39643c2d53262df7ad2635d095e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Harald=20J=C3=B8rgensen?= <58829763+adamjoer@users.noreply.github.com> Date: Wed, 25 Oct 2023 00:25:02 +0200 Subject: [PATCH] Shell: Add support for showing custom format time in prompt with "\D{}" --- Userland/Shell/Shell.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Userland/Shell/Shell.cpp b/Userland/Shell/Shell.cpp index a508660dfe..6f93bf816f 100644 --- a/Userland/Shell/Shell.cpp +++ b/Userland/Shell/Shell.cpp @@ -139,6 +139,15 @@ DeprecatedString Shell::prompt() const } else if (lexer.consume_specific('@')) { builder.append(Core::DateTime::now().to_deprecated_string("%I:%M %p"sv)); + } else if (lexer.consume_specific("D{"sv)) { + auto format = lexer.consume_until('}'); + if (!lexer.consume_specific('}')) + continue; + + if (format.is_empty()) + format = "%y-%m-%d"sv; + builder.append(Core::DateTime::now().to_deprecated_string(format)); + } else if (lexer.consume_specific('j')) { builder.appendff("{}", jobs.size());