From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2763 invoked from network); 9 Jun 1998 20:55:37 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 9 Jun 1998 20:55:37 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id QAA20922; Tue, 9 Jun 1998 16:50:36 -0400 (EDT) Resent-Date: Tue, 9 Jun 1998 16:49:55 -0400 (EDT) Message-ID: <005e01bd93e8$4da50cc0$cde8ec82@a205.ryd.student.liu.se> From: "=?iso-8859-1?Q?Johan_Sundstr=F6m?=" To: Subject: Emulating tcsh:s prompt Date: Tue, 9 Jun 1998 22:50:57 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 4.72.3110.1 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Resent-Message-ID: <"rOOk61.0.K45.n_PVr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1585 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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!". This only happens the first time the prompt is generated that minute, the second time a common HH:MM is generated. Example output near the hour shift for a prompt "%T>": 01:58> 01:58> 01:59> 01:59> Ding!> 02:00> 02:01> 02:01> I tried to emulate this behaviour using the precmd function, and even managed to do it in a rather ugly way: precmd () { PS1="`HH=\`date +%H\`;MM=\`date +%M\`;if [ -f /var/tmp/Hour -a $HH != \`cat /var/tmp/Hour\` -a $MM = 00 ];then echo Ding\!;else echo $HH:$MM;fi;echo $HH >/var/tmp/Hour`> " } In a more readable fasion: precmd () { PS1="`HH=\`date +%H\` MM=\`date +%M\` if [ -f /var/tmp/Hour -a $HH != \`cat /var/tmp/Hour\` -a $MM = 00 ] then echo Ding\! else echo $HH:$MM fi echo $HH >/var/tmp/Hour `> " } I was wondering, whether there is any way I can set an environment variable in the parent shell from this function. The kludge using /var/tmp/Hour to store the hour of the last prompt was a last resort when I didn't manage setting $Hour. Is there a way? How should it be done? I had hoped "exec export Hour=$HH" would do the job, but it didn't. I'm using the Linux version 3.0.5, if that should be of any relevance. /Johan Sundström