Printing Working Directory in CSH (or SH for that matter)

Jeff Liebermann jeffl at comix.UUCP
Tue Apr 30 18:31:48 AEST 1991


In article <46 at swatty.UUCP> root at swatty.UUCP (Superuser) writes:
>Does anybody know how to set the prompt in csh so that the current directory
>name (eg., /usr/lib/uucp) is printed (kind of like a dos $p$g), also can this
>be done is sh...

For csh, I use:

set	myport = `tty`			# get tty name
setenv	PORT	`basename $myport`	# remove /dev from login port
setenv	LOGNAME	`logname`		# get login name
					# redefine the cd command
alias	cd	'cd \!*; set prompt="[$PORT] [$LOGNAME] `pwd` -> "'
cd					# required to start prompt


For ksh, I use:

LOGNAME=`logname`		# Keep the logname
MACHINE=`uuname -l`		# Get the name of the machine
# MACHINE=`hostname`		# Get the name of the machine
TTY=`tty`			# Name of tty login port
PORT=`basename $TTY`		# Remove the /dev/ part
PS1='[$MACHINE $PORT] [$LOGNAME] $PWD =>  '	# set the main prompt


For sh, I suffer without...

---
# Jeff Liebermann   Box 272   1540 Jackson Ave     Ben Lomond    CA  95005
# (408)336-2558 voice  (408)429-0483 digital pager  wb6ssy  CIS:73557,2074 
# PC REPAIR & RF DESIGN.  Committee Against Double Spacing And Wide Margins.
# jeffl at comix.santa-cruz.ca.us  uunet!comix!jeffl  ucscc.ucsc.edu!comix!jeffl



More information about the Comp.unix.xenix.sco mailing list