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

Re: defining real time variables for a shell



On Mar 20,  6:05pm, Eric Smith wrote:
> 
> These values need to be updated at least daily and must be
> available to shells that are already open (I use screen and am
> lazy). 
> 
> I am thinking maybe to use a preexec function that parses a file
> with the values.

You'd want precmd, rather than preexec, I think.  It depends on what
you want to do with the values.  Re-parsing a file before every prompt
or command may be overkill; at the least, look at the zsh/sched module
and consider updating the variables less frequently.

(People tend to ask "How do I train a cat to dance?" when what they
really want to know is "How do I entertain twelve eight-year-olds
for two hours?"  A dancing cat might keep kids happy, but it might
not be the right or best solution.)

You say perhaps parse a file.  Where do the values in the file come
from?  The values will go into shell variables.  Why?  Is it because
you want to export them in the environment so external commands can
reference them?  If not, maybe there's no need for variables at all.
Or maybe $USD could be an expression that computes the number value,
and when you need the number you use ${(e)USD}.

Just food for thought.



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