home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / modes / J-Shell-1.1 / dot-cshrc < prev    next >
Encoding:
Text File  |  1993-03-06  |  4.3 KB  |  104 lines

  1. # $Id: dot-cshrc,v 1.0 1993/03/07 04:42:04 jct Exp $
  2.  
  3. ## This file contains a sample script showing how to set up tcsh to
  4. ## work properly with j-shell.  This script is for tcsh, but the steps
  5. ## and notes delimited by ## apply to all shells; please read through
  6. ## the comments in this file before referring to the sample script for
  7. ## your shell.
  8.  
  9. # Comments delimited by a single # are specific to csh/tcsh.
  10.  
  11. ## If we're running inside of Emacs, set up the shell to talk to
  12. ## J-Shell.  Note that we assume that we're also using J-Shell.  We
  13. ## *could* test for the JSHELL environment variable, but such
  14. ## variables are not passed to remote shells started via rlogin, so a
  15. ## remote shell would not get set up to talk to J-Shell.
  16.  
  17. if ("$TERM" == "emacs") then
  18.     stty nl -echo        # Keeps ^M from echoing
  19.  
  20.     ## Step A: Define variables containing the J-Shell message
  21.     ## intro; these messages should correspond to those defined in
  22.     ## the j-shell variables jsh-message-intro-pattern,
  23.     ## jsh-chdir-message-pattern, and jsh-rlogin-message-pattern.
  24.     ## If need to change the message patterns, don't forget to
  25.     ## change this shell script also.
  26.  
  27.     # Tcsh's built-in echo command doesn't understand the \nnn
  28.     # notation for characters such as ESCape.  Fortunately, there
  29.     # are several other ways to get an escape character into a
  30.     # variable; the most portable is to use awk.  If none of the
  31.     # techniques shown here work for your system, you'll need to
  32.     # use the cwdcmd program supplied with J-Shell.
  33.     set emacscd=`awk 'BEGIN { printf("%cEmAcScd", 27) ; exit}'`
  34.     set emacshost=`awk 'BEGIN { printf("%cEmAcShost", 27) ; exit}'`
  35.  
  36.     # Another technique is to use tr (thanks to Juergen Nickelsen
  37.     # <nickel@desaster.cs.tu-berlin.de> for suggesting this one):
  38. #    set emacscd=`echo @EmAcScd | tr @ '\033'`
  39. #    set emacshost=`echo @EmAcShost | tr @ '\033'`
  40.  
  41.     # In SunOS 4.1.n, you can also use /usr/5bin/echo to echo an
  42.     # escape character:
  43. #    set SYSV_ECHO=/usr/5bin/echo
  44. #    set emacscd=`$SYSV_ECHO "\033EmAcScd"`
  45. #    set emacshost=`$SYSV_ECHO "\033EmAcShost"`
  46.  
  47.     ## Step B: define some aliases to tell J-Shell what working
  48.     ## directory we're in and what host we're on.  Cwdcmd tells
  49.     ## J-Shell about the working directory, hostcmd tells it about
  50.     ## the host, and reorient tells it about both.
  51.     alias cwdcmd 'echo $emacscd $cwd' #See note below
  52.     alias hostcmd echo $emacshost `hostname`
  53.     alias reorient "hostcmd ; cwdcmd"
  54.  
  55.     ## NOTE: Because of the way J-Shell looks for the cwd message,
  56.     ##       the cwdcmd alias doesn't always work with some
  57.     ##       shells, when the current working directory is very
  58.     ##       long (> 128 characters for SunOS 4.1.1's csh, for
  59.     ##       example).  If you find that long directories are
  60.     ##       confusing J-Shell, consider using the cwdcmd program
  61.     ##       distributed with J-Shell instead of a shell alias;
  62.     ##       see the file cwdcmd.c.  To use cwdcmd: compile
  63.     ##       cwdcmd, place it somewhere in your PATH, and delete
  64.     ##       the above cwdcmd alias (or function, for shells such
  65.     ##       as ksh).
  66.  
  67.     ## Step C: define some aliases to call cwdcmd any time the
  68.     ## shell's working directory changes.  These aliases should
  69.     ## appear before any other aliases which call cd, chdir, or
  70.     ## popd, so that those aliases will tell J-Shell about the
  71.     ## change in working directory.
  72.  
  73.     # In tcsh, the cwdcmd alias is automatically executed every
  74.     # time the working directory changes; in plain csh, though, we
  75.     # have to alias each of the built-in commands that change
  76.     # working directory.
  77.     if (! $?tcsh) then
  78.         alias cd "cd \!* ; cwdcmd"
  79.         alias pushd "pushd \!* ; cwdcmd"
  80.         alias popd "popd ; cwdcmd"
  81.     endif
  82.  
  83.     ## Step D: Alias the commands that can change host and/or
  84.     ## working directory, so that they reorient J-Shell upon
  85.     ## exiting.  These aliases are necessary because other shells
  86.     ## can change the working directory; upon leaving another
  87.     ## shell, there is an implicit change in directory (the parent
  88.     ## shell's cwd), which we need to tell J-Shell about.
  89.  
  90.     alias rlogin "rlogin \!* ; reorient" 
  91.     alias sh "sh \!* ; reorient"
  92.     alias ksh "ksh \!* ; reorient"
  93.     alias csh "csh \!* ; reorient"
  94.     alias tcsh "tcsh \!* ; reorient"
  95.     alias zsh "zsh \!* ; reorient"
  96.     alias bash "bash \!* ; reorient"
  97.     alias tcl "tcl \!* ; reorient"
  98.  
  99.     ## Step E: reorient this shell--necessary for sub-shells that
  100.     ## start up in a different directory from their parent (an
  101.     ## rlogin, for example).
  102.     reorient
  103. endif
  104.