[gnu.emacs] Multiple shells

ho@LA.TIS.COM (Hilarie K. Orman) (03/16/89)

It is relatively easy to hack shell.el to allow multiple shell
processes, each in its own buffer.  This largely eliminates the need
for job control, and it is an excellent way of organizing one's work.
I normally work with 2-5 shells at a time.  Does anyone else work this
way?  The only major problem I have had with shell windows is that
passwords from telnet and rlogins and su's are visible, and I finally
had to resort to implementing a command to grab and stuff without
echoing. 

kayvan@APPLE.COM (03/17/89)

> Date: Wed, 15 Mar 89 23:13:40 PST
> From: apple!la.tis.com!ho (Hilarie K. Orman)
> 
> It is relatively easy to hack shell.el to allow multiple shell
> processes, each in its own buffer.

I got tired of people hacking various shell.el's to put in multiple
shell buffers. So I wrote my own function (which I bind to C-M-r)
to automatically rename the current buffer. It is appended to the
end of this message.

This function creates names like "1:*shell*" "2:*shell*", etc., making
it easy to switch-buffer with completion.

> This largely eliminates the need
> for job control, and it is an excellent way of organizing one's work.
> I normally work with 2-5 shells at a time.  Does anyone else work this
> way?

Yes. I love it. Once inside emacs I never have to leave. If I need to do
a screen-oriented thing, I just drop to a subshell (C-z on SysV) and
do it and return back to my emacs.

> The only major problem I have had with shell windows is that
> passwords from telnet and rlogins and su's are visible, and I finally
> had to resort to implementing a command to grab and stuff without
> echoing. 

Try using the new cmushell package that came out recently.
It does filename completions, among other nifty things as well.
My cmushell-load-hook for it is set in my .emacs as follows:

(setq cmushell-load-hook
      '((lambda () (define-key cmushell-mode-map "\C-c\C-i" 'send-invisible))))

This sets the key-esquence C-c C-i (i for invisible) to the send-invisible
function which grabs text invisibly. This means that after typing su in
my "1:*cmushell*" buffer, I type C-c C-i before typing in the password.

Anyways, here is the rename function.

			---Kayvan

---------------------------- cut here -----------------------------------
;
; rename.el - Functions to rename buffers.
;
; This is especially useful for shell process buffers that need to be
; renamed for multiple buffers to exist.
;
; Author: Kayvan Sylvan
;

(defvar rename-format "%d:%s"
  "*Format string that rename-to-new-name uses to generate new name.
The number comes first so that the least substring matches buffer names.")

(defun rename-to-new-name ()
  "Rename current buffer to new name not already taken. The new buffer names
are in the format specified by rename-format (using old name and a number).
This function is useful for creating multiple shell process buffers"
  (interactive)
  (let (new-name (old-name (buffer-name (current-buffer))) (i 1))
    (while (get-buffer (setq new-name (format rename-format i old-name)))
      (setq i (1+ i)))
    (rename-buffer new-name)
    (set-buffer-modified-p (buffer-modified-p)))) ; force mode line update

Kayvan Sylvan @ Transact Software, Inc. -*-  Mountain View, CA (415) 961-6112
Internet: mrspoc!kayvan@apple.com UUCP: ...!{apple,pyramid,mips}!mrspoc!kayvan

piet@ruuinf (Piet van Oostrum) (03/17/89)

In article <8903160713.AA03138@la.tis.com>, ho@LA (Hilarie K. Orman) writes:
 `It is relatively easy to hack shell.el to allow multiple shell
 `processes, each in its own buffer.  This largely eliminates the need
 `for job control, and it is an excellent way of organizing one's work.
 `I normally work with 2-5 shells at a time.  Does anyone else work this
 `way? 

Yes, I have a command that spawns a (C-)shell and remembers the current
directory in the buffer name. So I usually have a shell running on each
directory where I am issueing commands.

(defun csh ()
  "Run an inferior c-shell.
The buffer is put in shell-mode, giving commands for sending input
and controlling the subjobs of the shell.  See shell-mode.
See also variable shell-prompt-pattern.
Note that many people's .cshrc files unconditionally clear the prompt.
If yours does, you will probably want to change it."
  (interactive)
  (require 'shell)
  (switch-to-buffer
   (let ((name "csh"))
     (make-shell (concat name "-" default-directory)
		 name
		 (if (file-exists-p (concat "~/.emacs_" name))
		     (concat "~/.emacs_" name))
		 "-i"))))
-- 
Piet van Oostrum, Dept of Computer Science, University of Utrecht
Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
Telephone: +31-30-531806. piet@cs.ruu.nl (mcvax!hp4nl!ruuinf!piet)