Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!crdgw1!uunet!comix!jeffl From: jeffl@comix.UUCP (Jeff Liebermann) Newsgroups: comp.unix.xenix.sco Subject: Re: Printing Working Directory in CSH (or SH for that matter) Summary: cwd in prompt Keywords: csh prompt alias cd Message-ID: <112@comix.UUCP> Date: 30 Apr 91 08:31:48 GMT References: <46@swatty.UUCP> Distribution: usa Organization: COmmittee to Maintain Independent Xenix Lines: 37 In article <46@swatty.UUCP> root@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@comix.santa-cruz.ca.us uunet!comix!jeffl ucscc.ucsc.edu!comix!jeffl