[comp.emacs] Change prompt in M-x shell buffer?

ansley@sunybcs.uucp (William Ansley) (09/07/88)

I would like to be able to change my prompt when I start running a shell
process in a buffer with 'M-x shell'.  That is, I want to reset the prompt
that will appear in the shell process running in the buffer.  I assume this
can be done with 'shell-mode-hook', but so far I haven't been able to figure
out how.

I do have a reason for this.  I use the tcsh (a C shell with file name
completion and command line editing) shell normally but I use a csh when in
emacs, since emacs can't deal with all the extra features of tcsh.  In other
words I have 'explicit-shell-file-name' and 'shell-file-name' set to /bin/csh
in my .emacs file.  I use special tcsh functions in my prompt, so in the shell
buffer my prompt turns into garbage, since csh doesn't understand the tcsh
prompt commands.

Thanks very much in advance for any help.  Please respond by email unless you
think your solution is of general interest.  If I get an indication there is
enough interest, I'll summarize to this group.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 William H. Ansley, Dept. of CS, 226 Bell Hall, SUNY at Buffalo, NY  14260
 ansley@gort.cs.buffalo.EDU | ansley@sunybcs.BITNET | ansley@sunybcs.UUCP
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

jr@bbn.com (John Robinson) (09/08/88)

In article <1094@cs.Buffalo.EDU>, ansley@sunybcs (William Ansley) writes:
>  I use the tcsh (a C shell with file name
>completion and command line editing) shell normally but I use a csh when in
>emacs, since emacs can't deal with all the extra features of tcsh.  In other
>words I have 'explicit-shell-file-name' and 'shell-file-name' set to /bin/csh
>in my .emacs file.  I use special tcsh functions in my prompt, so in the shell
>buffer my prompt turns into garbage, since csh doesn't understand the tcsh
>prompt commands.

tcsh defines the shell variable `tcsh' to be true before running your
.cshrc, so you can conditionalize the shell startup this way.  For
example, my .cshrc includes:

  if ( $?tcsh ) set prompt="[$HOST.%\!] "

[where I have already set up $HOST] because the syntax for inserting
the line numebr into the prompt is different for tcsh and csh.  I also
conditionalize the tcsh key bindings this way.
--