home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / shell / 3859 < prev    next >
Encoding:
Text File  |  1992-09-08  |  1.5 KB  |  42 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!think.com!snorkelwacker.mit.edu!thunder.mcrcim.mcgill.edu!bruno
  3. From: bruno@thunder.mcrcim.mcgill.edu (Bruno Hall)
  4. Subject: Re: Need help putting PWD in PROMPT
  5. Message-ID: <1992Sep8.210818.23119@thunder.mcrcim.mcgill.edu>
  6. Organization: McGill University Broom Closet
  7. References: <1992Sep8.152514.24851@orlith.bates.edu>
  8. Date: Tue, 8 Sep 92 21:08:18 GMT
  9. Lines: 27
  10.  
  11. pbeach@abacus.bates.edu (Preston Beach) writes:
  12.  
  13. >  I want to get my prompt to give my current working directory all the time.
  14. >I need this for an Ultrix and BSD system. If anyone knows of a script or
  15. >shell file which will do this please send it my way. Thanks very much.
  16. >                -Preston
  17. >p.s. I am using csh. btw
  18.  
  19. Tsk.  You should be using tcsh, which has this feature built in. :-) :-)
  20.  
  21. Here's what I use (and it's not dependent on tcsh):
  22.  
  23. set hnm =  `hostname | sed 's/\..*//'`
  24. if $?prompt then
  25.   alias cd 'set old=$cwd; chdir \!*; dirs; resetprompt'
  26.   alias pushd 'pushd \!* ; resetprompt'
  27.   alias popd 'popd \!* ; resetprompt'
  28.   alias resetprompt 'if "$cwd:q" == "/" set prompt = "${hnm}:[/] >"; if "$cwd:q" != "/" set prompt = "${hnm}:[$cwd:t] > "'
  29.   resetprompt
  30. endif
  31.  
  32. Plus, you get to use this:
  33.  
  34. alias back 'set whereto=$old; set old=$cwd; cd $whereto; unset whereto'
  35.  
  36. Bruno
  37. -- 
  38. /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
  39. Bruno Hall  |  VE2HUM  |  bruno@mcrcim.mcgill.edu         
  40. McGill Research Centre for Intelligent Machines - Controls Group
  41. New systems generate new problems -- Join the Flat Earth Society.
  42.