tags:

views:

274

answers:

6

I am getting more and more used to doing everything from inside emacs, but it seems that eshell, shell and term will only run one instance each. Is there a way to run multiple terminals (preferably term) inside emacs?

+2  A: 

http://www.emacswiki.org/emacs/MultiTerm

aaa
+11  A: 

Use the command M-x rename-buffer to give the current shell buffer a new name, then you can start a new shell.

Scott Wales
You can also use `M-x rename-uniquely` to let emacs find the new name
Rémi
+3  A: 

You can always create a new shell with C-u M-x shell

dnolen
depends on the underlying OS, whether you get ANOTHER shell or jump to the existing one
Peter Miehle
+1  A: 

You can rename a term and start a new one. I'm using something like that, took it from someone else .emacs.

(require 'term)
(defun visit-ansi-term ()
  "If the current buffer is:
     1) a running ansi-term named *ansi-term*, rename it.
     2) a stopped ansi-term, kill it and create a new one.
     3) a non ansi-term, go to an already running ansi-term
        or start a new one while killing a defunt one"
  (interactive)
  (let ((is-term (string= "term-mode" major-mode))
        (is-running (term-check-proc (buffer-name)))
        (term-cmd "/bin/bash")
        (anon-term (get-buffer "*ansi-term*")))
    (if is-term
        (if is-running
            (if (string= "*ansi-term*" (buffer-name))
                (call-interactively 'rename-buffer)
              (if anon-term
                  (switch-to-buffer "*ansi-term*")
                (ansi-term term-cmd)))
          (kill-buffer (buffer-name))
          (ansi-term term-cmd))
      (if anon-term
          (if (term-check-proc "*ansi-term*")
              (switch-to-buffer "*ansi-term*")
            (kill-buffer "*ansi-term*")
            (ansi-term term-cmd))
        (ansi-term term-cmd)))))

Or you can have just one and start a screen session in it.

wu
+1  A: 

I personally use a screen-like package I wrote, and there's another version available on the wiki here: elscreen. It provides convenient key bindings to jump to/between the different shells.

Trey Jackson
+3  A: 

You just have to rename the buffer, here's a function to start zsh and prompt for the buffer name:

(defun zsh (buffer-name)
  "Start a terminal and rename buffer."
  (interactive "sbuffer name: ")
  (term "/bin/zsh")
  (rename-buffer buffer-name t))
Harpo