Path: utzoo!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!src.honeywell.com!msi.umn.edu!cs.umn.edu!uc!shamash!hare!ddh From: ddh@hare.cdc.com (Dan Horsfall) Newsgroups: comp.unix.wizards Subject: Re: How do I ... (NOT a FAQ) Message-ID: <31139@shamash.cdc.com> Date: 7 Mar 91 21:35:15 GMT References: <15710@mendip.UUCP> <668118083.19530@mindcraft.com> <506@bria> <1991Mar6.164033.8173@athena.mit.edu> Sender: usenet@shamash.cdc.com Reply-To: ddh@dash.udev.cdc.com (Dan Horsfall) Distribution: usa Organization: Control Data Corp, Arden Hills, MN Lines: 70 In article <1991Mar6.164033.8173@athena.mit.edu> mars@athena.mit.edu (Anita Hsiung) writes: > In article <506@bria> uunet!bria!mike writes: > >In an article, mindcraft.com!ronnie (Ronnie Kon) writes: > >>In article <15710@mendip.UUCP> mhr@mendip.UUCP (Mark Hull-Richter) writes: > >>> > >>>How do I get the current time into my command line prompt? > >>> > > >The answer is: it depends. Some shells allow for the execution of embedded > >commands in a prompt; the Big Three (sh, csh, ksh) do not. > > I use csh and it works for me. My prompt definition looks like: > > set prompt="{!} (labs-n) `date +%T`${cwd}% " > > resulting in: > > {43} (labs-n) 11:36:13 /usr/ahsiung% > > Of course, the time only updates when I "cd". > > -- Anita -- My man pages for csh describe the pre-defined variable "prompt" thusly: prompt The string which is printed before each command is read from an interactive terminal input. If a ! appears in the string, it will be replaced by the current event number unless a preceding \ is given. The sequence \\ is replaced with a single \. The prompt should only be set by the user if it is already defined so that it will not be printed when processing shell scripts by using the statement if ( $?prompt ) set prompt='\!% ' If the sequence \@x appears, where x is one of the characters listed below, then it will be replaced by the current time and date in the indicated format. R time as HH:MM AM/PM, e.g. 8:40PM r time as HH:MM:SS AM/PM, e.g. 08:40:25 PM m month of year - 01 to 12 d day of month - 01 to 31 y last 2 digits of year - 00 to 99 D date as mm/dd/yy H hour - 00 to 23 M minute - 00 to 59 S second - 00 to 59 T time as HH:MM:SS j day of year - 001 to 366 w day of week - Sunday = 0 a abbreviated weekday - Sun to Sat h abbreviated month - Jan to Dec n insert a new-line character t insert a tab character The default prompt is %, or # for the super-user. In this manner, one need not change directories to change the prompt. Hope this works for you. -- Horse + Control Data Corporation Dan Horsfall +1-612-482-4622 + 4201 Lexington Ave North Internet ddh@dash.udev.cdc.com + Arden Hills MN 55126 USA