How do I ... (NOT a FAQ)
Michael Pechner
pechner at ddtg.com
Fri Apr 19 02:29:28 AEST 1991
In article <506 at bria> uunet!bria!mike writes:
>In an article, mindcraft.com!ronnie (Ronnie Kon) writes:
>>In article <15710 at mendip.UUCP> mhr at mendip.UUCP (Mark Hull-Richter) writes:
>>>
>>>How do I get the current time into my command line prompt?
>>>
>> The construct `command` (note the use of accent grave (`) instead
>>of apostrophe (') inserts the result of the command into the command line.
>>(Refer to the man page for your shell for a more complete explanation). I
>>believe this facility is present in Bourne shell; I know it is in C and Korn
>>shells.
>
>If you happened to read the question, the original poster was NOT asking how
>to insert the date into the command line -- he was asking how to insert the
>date in the 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.
>
>--
In ksh I have a function to put in your .kshrc file that will insert time, or
other if you want. Most ksh people know about this one.
unalias cd
function _cd {
cd $@ ;
PS1=`date '+%H:%M '``hostname`".""$LOGNAME"" ""$PWD"">"
export PS1
}
alias cd='_cd'
My prompt prints "hh:mm mikey.pechner /whatewver/idunno>"
--
pechner at mikey.ddtg.com (Michael Pechner) | Pizza Probably The Worlds Most
DuPont Design Technologies Group | Perfect Food.
Santa Clara, Ca | Carbo, Meat, Dairy, And Veggie
| All Food Groups In One.
More information about the Comp.unix.wizards
mailing list