Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cuae2!ihnp4!houxm!ho95e!wcs From: wcs@ho95e.UUCP Newsgroups: comp.unix.questions,comp.unix.wizards Subject: Re: Re: Prompt changing on the fly Message-ID: <1308@ho95e.ATT.COM> Date: Mon, 2-Feb-87 18:43:56 EST Article-I.D.: ho95e.1308 Posted: Mon Feb 2 18:43:56 1987 Date-Received: Tue, 3-Feb-87 22:37:09 EST References: <432@ethz.UUCP> <2935@diku.UUCP> Reply-To: wcs@ho95e.UUCP (46133-#Bill.Stewart,2G202,x0705,) Distribution: world Organization: AT&T Bell Labs 46133, Holmdel, NJ Lines: 28 Xref: watmath comp.unix.questions:886 comp.unix.wizards:795 In article <2935@diku.UUCP> storm@diku.UUCP writes: >In article <432@ethz.UUCP> wyle@ethz.UUCP (Mitchell Wyle) writes: >>Does anyone out there have a shell script / program to change >>the prompt DYNAMICALLY after each [CR]? > >You cannot use a shell script or a program to change the shell prompt >dynamically, because the PS1/prompt variables are local to the shell, >and therefore they can only be changed by the shell itself. If all you want to do is set the prompt based on a few variables (process id, current directory, some-shell-variable, history-number), ksh and csh have some hooks to do these. I don't know csh, but I've seen people whose prompt includes a number incremented by 1 each command; makes it easier to use csh's boring version of history. Ksh (which is upward-compatible with sh, and has decent history), allows you to evaluate variables each time you access PS1. Thus, my PS1 is set to PS1='e!!${PWD}> ' which looks like e!/usr/spool/news> (the ! is doubled to prevent csh-like history-number substitution) I don't think you can do execution at the prompt (which would be really slow), but the newer versions of ksh let you set SECONDS to get a crude clock. SECONDS=0; export SECONDS PS1='Logged in $SECONDS: ' You can also set MAILPATH to check files other than just $MAIL. -- # Bill Stewart, AT&T Bell Labs 2G-202, Holmdel NJ 1-201-949-0705 ihnp4!ho95c!wcs