1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

Shell: Add support for showing custom format time in prompt with "\D{}"

This commit is contained in:
Adam Harald Jørgensen 2023-10-25 00:25:02 +02:00 committed by Ali Mohammad Pur
parent e40955e9c6
commit 050c73d301

View file

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