From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3383 invoked from network); 9 Jun 1998 22:20:40 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Jun 1998 22:20:40 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id SAA23385; Tue, 9 Jun 1998 18:15:14 -0400 (EDT) Resent-Date: Tue, 9 Jun 1998 18:14:54 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980609151533.ZM7488@candle.brasslantern.com> Date: Tue, 9 Jun 1998 15:15:33 -0700 In-Reply-To: <005e01bd93e8$4da50cc0$cde8ec82@a205.ryd.student.liu.se> Comments: In reply to "=?iso-8859-1?Q?Johan_Sundstr=F6m?=" "Emulating tcsh:s prompt" (Jun 9, 10:50pm) References: <005e01bd93e8$4da50cc0$cde8ec82@a205.ryd.student.liu.se> X-Mailer: Z-Mail Lite (5.0.0 30July97) To: "=?iso-8859-1?Q?Johan_Sundstr=F6m?=" , Subject: Re: Emulating tcsh:s prompt MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"lUIek.0.ei5.SFRVr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1586 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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".