Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Date format in prompt



On Sun, Nov 22, 2020 at 2:00 PM Vin Shelton <acs@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> I've used prompt bart for as long as I can remember.

Nice to know somebody else does. :-)

> But I'm an ISO date kind of guy, and I'd like to use %D{%Y-%m-%d} to get a four-digit year.  I've grovelled through the source code, but I can't figure out how to make the change.  Is there an easy way to do what I want?

It's this line in prompt_bart_ps1:

    date="%{$fg[%D]%}%D$rs"     # Prefer "%{$fg[%D]%}%W$rs" in the USA?

Just change to

    date="%{$fg[%D]%}%D{%Y-%m-%d}$rs"

If changing in real time in an interactive shell (e.g. with zed -f),
you then have to re-run prompt_bart_ps1




Messages sorted by: Reverse Date, Date, Thread, Author