home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / aix / 8950 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  2.8 KB

  1. Path: sparky!uunet!seismo!darwin.sura.net!wupost!cs.utexas.edu!usc!sol.ctr.columbia.edu!ira.uka.de!chx400!aragorn.unibe.ch!iacrs1!haedener
  2. From: haedener@iacrs1.unibe.ch (Konrad Haedener)
  3. Newsgroups: comp.unix.aix
  4. Subject: Re: Where are you?
  5. Keywords: PATH, ksh, CWD, prompt
  6. Message-ID: <1992Aug20.133152.10514@aragorn.unibe.ch>
  7. Date: 20 Aug 92 13:31:52 GMT
  8. References: <1992Aug19.122848.18225@aragorn.unibe.ch> <1133@epd74hp.nluug.nl>
  9. Sender: haedener@iacrs1 (Konrad Haedener)
  10. Reply-To: haedener@iacrs1.unibe.ch
  11. Followup-To: <1133@epd74hp.nluug.nl>
  12. Organization: University of Berne
  13. Lines: 73
  14.  
  15. In article <1133@epd74hp.nluug.nl>, snrbru@nluug.nl (R. M. Bruijne) writes:
  16.  [ ... ]
  17. |> Maybe a better idea is to
  18. |> use PS1 for this purpose. The definition I use is:
  19. |>      'PS1='^[[?E^[[?02T${PWD}^[[?F'"$PS1"; export PS1'
  20.  [ ... ]
  21.  
  22. Besides the problem you mention with a garbled status line, your approach
  23. based on PS1 has the following drawbacks:
  24.  
  25. o  as your status line grows with increasing cwd depth, the shifting point
  26.    of the command line (displayed as '<' by ksh) moves to the left in parallel;     with a 50 char status line and '$ ' as your prompt, e.g., your command line 
  27.    will be rolled over by ksh already after typing in 11 characters
  28.    (in a 80x25 aixterm).
  29.  
  30. o  aixterm has to interpret a lot of esc sequences with each PS1 issued;
  31.    even without ever changing directories, you're doing more i/o.
  32.  
  33. My approach based on aliasing cd does indeed have the drawback of a stale
  34. status line after telnet'ing or rlogin'ing to another host where the same
  35. .kshrc is in effect; you can, however, always update your line by a 'cd .'
  36. I don't know of a way to get around this. The problem with subshells (as long
  37. as they are ksh's) and su's is fixed in the following version (do keep in
  38. mind though, that the whole thing is still a quick shot and not a mature
  39. shell environment; you may still encounter some side effects):
  40.   === cut ===
  41. tty -s
  42. if [ -z "${0#/bin/ksh}" -o -z "${0#-ksh}" -o -z "${0#ksh}" -a $? = 0 ] ; then
  43.    INTERACTIVE=on
  44. else
  45.    INTERACTIVE=off
  46. fi
  47.  
  48. if [ $INTERACTIVE = "on" ] ; then
  49.    if [ $TERM = aixterm ] ; then
  50.       OPWD=$PWD
  51.       HOST=`uname -n`
  52.       BOLD="\033[1m"
  53.       TSL="\033[?1T"
  54.       FSL="\033[?F"
  55.       EL="\033[K"
  56.       SGR0="\033[0;10m"
  57.       KCUU1="\033[A"
  58.    
  59.       cwd () {
  60.           cd $*
  61.           echo $TSL$EL"You are on "$HOST" in "$BOLD$PWD$SGR0$FSL$KCUU1
  62.       }
  63.       alias cd=cwd
  64.    fi
  65.  
  66.    if [ $TERM = vt220 ] ; then
  67.    
  68.       cwd () {
  69.           cd $*
  70.           PS1=$PWD"> "
  71.           export PS1
  72.       }
  73.       alias cd=cwd
  74.    fi
  75. fi
  76.  
  77. if [ $INTERACTIVE = "on" ] ; then
  78.    echo
  79.    cd .
  80.    trap "cd $OPWD" EXIT
  81. fi
  82.   === cut ===
  83. -- 
  84. Konrad Haedener                             Phone: +41 31 65 42 25
  85. Institute for Physical Chemistry            FAX:   +41 31 65 44 99
  86. University of Berne
  87. Switzerland                                 haedener@iacrs1.unibe.ch
  88.