Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Emulating tcsh:s prompt
- X-seq: zsh-users 1586
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxx>
- To: "Johan Sundström" <johsu650@xxxxxxxxxxxxxx>, <zsh-users@xxxxxxxxxxxxxxx>
- Subject: Re: Emulating tcsh:s prompt
- Date: Tue, 9 Jun 1998 15:15:33 -0700
- In-reply-to: <005e01bd93e8$4da50cc0$cde8ec82@xxxxxxxxxxxxxxxxxxxxxxx>
- References: <005e01bd93e8$4da50cc0$cde8ec82@xxxxxxxxxxxxxxxxxxxxxxx>
On Jun 9, 10:50pm, =?iso-8859-1?Q?Johan_Sundstr=F6m?= wrote:
> Subject: Emulating tcsh:s prompt
> I'm trying to emulate tcsh:s cool prompt parameter %T in zsh using the
> precmd function. Tcsh:s version of %T gives a five character long field in
> the format HH:MM, with a slight exception; if the prompt is displayed on a
> full hour (MM=00), the text changes to "Ding!".
PS1="%(t.Ding\!.%D{%I:%M})> "
> ... the second time [that minute] a common HH:MM is generated.
Hardly seems worth the effort, but
precmd() {
thisminute=$(print -P %D{%M})
[[ $thisminute = ${lastminute:-0} ]] && {
PS1="%D{%I:%M}> " ||
PS1="%(t.Ding\!.%D{%I:%M})> " }
lastminute=$thisminute
}
> I was wondering, whether there is any way I can set an environment variable
> in the parent shell from this function.
Any variable you set in a function is set in the "parent" shell. Functions
run in the same context as builtins, by definition.
> I had hoped "exec export Hour=$HH" would do the job, but it didn't.
Leave off the "exec".
Messages sorted by:
Reverse Date,
Date,
Thread,
Author