[TriLUG] BASH Question: Putting relative local time and user environment v ariables in the prompt

Jaimie Livingston Jaimie.Livingston at haht.com
Fri Sep 27 23:08:50 EDT 2002


The timezone to use is not my decision, and the problem provides the
opportunity for some much needed practice with the shell...

If I can't work it out with a few more hours, I'll abandon the problem and
move on...

Jaimie

-----Original Message-----
From: Jon Carnes [mailto:jonc at nc.rr.com] 
Sent: Friday, September 27, 2002 8:23 PM
To: trilug at trilug.org
Subject: Re: [TriLUG] BASH Question: Putting relative local time and user
environment v ariables in the prompt


On Fri, 2002-09-27 at 16:26, Jaimie Livingston wrote:
> Here's the situation...
> I have an OpenBSD system that is used by several staffers in the US 
> and Europe. The server is set to use GMT as the localtime, but I would 
> like to have a bash prompt that displays the users time for their 
> timezone.

Boy talk about a waste of time...

If this is the server that I'm thinking of, then it really doesn't need to
be set to GMT, you can save yourself some grief and set the server to the
proper timezone.
>  
> I assume, possibly incorrectly, that I will have to set the TZ environ 
> variable for the user via a login script, and then use /t (or /T, or 
> /@) to display the time in the prompt, and echo the setting for the TZ 
> environ variable to indicate their timezone.
>  
> I have two problems:
> 1) I can't figure out which dot file I should set the TZ prompt from.
>    I've tried the following (assuming US Eastern as the timezone):
>         in .bashrc and .bash_profile
>                         TZ=:/US/Eastern 
>         and
>             TZ=/usr/share/zoneinfo/US/Eastern
>  
>                 in .login and .profile
>                         TZ=:/US/Eastern
>                         export TZ
>                 and
>             TZ=/usr/share/zoneinfo/US/Eastern
>             export TZ
>  
>     But to no avail. The time is still returned using GMT as set with 
> /etc/localtime.
>     Perhaps I am misreading the various Bash HOWTO's...

Modifying the TZ variable doesn't seem to do anything to the time displayed
by my bash prompt... I'm using bash version 2.05.1

>  
> 2) I don't know how to echo the TZ environment variable in a prompt, 
> can't find a reference for doing it, and don't even know if it's 
> possible... Any information you can provide would be helpful...

You can look at all the environment variables by simply typing "set". If you
want to isolate the TZ variable then, "set |grep TZ".

===
I can think of one way to do this - but it's not worth the effort... 
I read an article about two years ago that detailed how to run a
program/script with every prompt, and display the output as part of the
prompt.

I think the author wanted to display the size of the directory on the
prompt. Then he could simply "cd" to a directory to see how much space was
used there.  

I remember thinking that it was a stupid bash trick!

Jon

_______________________________________________
TriLUG mailing list
    http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ:
    http://www.trilug.org/~lovelace/faq/TriLUG-faq.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.trilug.org/pipermail/trilug/attachments/20020927/a9284ee9/attachment.html>


More information about the TriLUG mailing list