[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

timezone display in WSL version of F29



Long ago I personalized the PS1 environment variable that constructs the
prompt displayed by bash. In most RHEL/CentOS/Fedora systems I make the
following modification to /etc/bashrc. I comment out the stock prompt and
add my enhanced code:

#  [ "$PS1" = "\\s-\\v\\\$ " ] && PS1=[\u@\h \W]\\$ "
   [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="\n\\033m`cat
/etc/redhat-release`\n\\033[1;34m`date +%A` - `date +%B` `date +%d`,
'date +%Y`  \\033[0;32m\t `date +%Z`\n\\033[036m[\u@\h:\l]
\\033[1;33m\w\\033[0;37m]\n\\$ "

This custom PS1 generates a nifty compound prompt in full color:

Fedora release 29 (Twenty Nine)                 <-- bold red
Saturday - February 09, 2019  15:57:23 CST      <-- bold blue + green
[doc@puma:1] ~                                  <-- cyan + bold yellow
$ _                                             <-- white

I just modified /etc/bashrc in the Windows Services for Linux (WSL)
version of Fedora 29, and there's a glitch. The time zone displayed is
'STD' instead of 'CST'.

When I type 'timedatectl' a native F29 I get this:

$ timedatectl
               Local time: Sat 2019-02-09 16:10:19 CST
           Universal time: Sat 2019-02-09 22:10:19 CST
                 RTC time: Sat 2019-02-09 22:10:19
                Time zone: America/Chicago (CST, -0600)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

But when I type the same command in the WSL F29 I get this:

$ timedatectl
System has not been booted with systemd as init system (PID 1). Can't
operate.
Failed to create bus connection. Host is down.

This is not surprising since the WSL version of F29 has been cobbed to
operate under a shim which redirects many familiar system environment
requests not to a real Linux kernel, but upwards to the host Windows
kernel which obviously doesn't speak systemd.

Can anyone suggest a change to the "date +%Z" element that will result in
a correct "CST" timezone display in the prompt?

--Doc
Robert G. (Doc) Savage
Fairview Heights, IL

"Perfection is the enemy of good enough."
          -- Admiral of the Fleet Sergei G. Gorshkov

-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.