current pwd in prompt

Lenny Tropiano lenny at icus.UUCP
Sun Feb 7 04:36:30 AEST 1988


In article <11656 at brl-adm.ARPA> Mensing.HENR801c at Xerox.COM writes:
|>
|>Can anyone explain to me how to get my prompt to be the current directory? I
|>have tried several methods without any success. It seems that no matter what
|>method I try, the prompt is evaluated once and never changes.
|>
|>Just in case it matters, I am on an AT&T 3B2/400 running korn shell under UNIX
|>System V.3.1.
|>

This KORN SHELL SCRIPT was in the February, 1988 issue of UNIX WORLD magazine
(page 109 - Wizards Grabbag)

NOTE:  Aspen Technologies is the only company selling the TRUE Korn shell
       commerically.

       I have no relation to Aspen Technologies or UNIX World Magazine.

-- cut here for ksh script -- -- cut here for ksh script --

# @(#) Put the current directory in your shell prompt
# Author: F.C. Arndt, Aspen Technologies, Inc.
# '_cd' and 'cd' are set up to provide
# a PS1 prompt with the current directory.
# $PS0 can be set to have the user specific portion

function _cd {
	typeset t1		# define a local variable
	'cd' $1			# now change directory
# Reduce the path length to 15 chars:
	if [ ${#PWD} -gt 15 ]
	then
		t1="${PWD%/*???????????????}"
		PS1="$PS0...${PWD#$t1/}> "
	else
		PS1="$PS0$PWD> "
	fi
}
#
alias -x cd=_cd
PS1="$PS0$PWD> "
#
typeset -fx _cd

-- 
============================ US MAIL:   Lenny Tropiano, ICUS Computer Group
 IIIII   CCC   U   U   SSSS             PO Box 1
   I    C   C  U   U  S                 Islip Terrace, New York  11752
   I    C      U   U   SSS   PHONE:     (516) 968-8576 [H] (516) 582-5525 [W] 
   I    C   C  U   U      S  AT&T MAIL: ...attmail!icus!lenny  TELEX: 154232428
 IIIII   CCC    UUU   SSSS   UUCP:
============================    ...{uunet!godfre, harvard!talcott}!\
                   ...{ihnp4, boulder, mtune, bc-cis, ptsfa, sbcs}! >icus!lenny 
"Usenet the final frontier"        ...{cmcl2!phri, hoptoad}!dasys1!/



More information about the Comp.unix.questions mailing list