Create more than one eshell instance in emacs
Asked Answered
S

8

7

Think: tiling my emacs window with eshells, a la xmonad. Is this possible? I can M-x eshell to open the first eshell instance but future invocations just focus the first instance.

Springs answered 29/3, 2010 at 20:21 Comment(0)
C
16

You can do this:

`C-u M-x eshell`

This will create *eshell*, *eshell*<2>, and so on.

Cozza answered 29/3, 2010 at 20:36 Comment(0)
S
7

My preferred approach is to create named shells:

(defun make-shell (name)
  "Create a shell buffer named NAME."
  (interactive "sName: ")
  (setq name (concat "$" name))
  (eshell)
  (rename-buffer name))

is the gist. Then M-x make-shell name will create the desired shell.

Sharpsighted answered 29/3, 2010 at 21:52 Comment(0)
I
4

The docstring for eshell states that "A nonnumeric prefix arg means to create a new session." I typed M-- M-x eshell over and over, and each time it opened a new eshell buffer.

Inharmonious answered 29/3, 2010 at 20:26 Comment(1)
Damn. Your comment hadn't been written when I started my answer :)Cozza
A
1

C-u M-x eshell works great, but I prefer named shells - make-shell approach, is useful when switching buffers

Ashur answered 18/5, 2011 at 6:10 Comment(0)
O
0

Invoking GNU Screen is another option for those using ansi-term

Openair answered 10/11, 2010 at 10:40 Comment(0)
H
0

Mybe, the following solution is better. Because the eshell buffer is determined by the value of eshell-buffer-name. You need not to rename the buffer.

(defun buffer-exists (bufname)   
  (not (eq nil (get-buffer bufname))))

(defun make-shell (name)
  "Create a shell buffer named NAME."
  (interactive "sName: ")
  (if (buffer-exists "*eshell*")
      (setq eshell-buffer-name name)
    (message "eshell doesnot exists, use the default name: *eshell*"))
  (eshell))
Hunsinger answered 6/5, 2014 at 1:52 Comment(0)
S
0

Expanding on make-eshell, this creates an eshell appending the next counter, so it's like eshell1, eshell2, etc.:

(lexical-let ((count 1))
  (defun make-eshell-next-number ()
    (interactive)
    (eshell)
    (rename-buffer (concat "*eshell" (number-to-string count) "*"))
    (setq count (1+ count))))
Southwards answered 21/11, 2015 at 1:35 Comment(0)
M
0

Here is my implementation of new eshell buffer / instance.

(defun eshell-new-buffer (args)
  "Create a new eshell buffer."
  (interactive "P")
  (eshell "new")
  )


(global-set-key (kbd "C-c e e") 'eshell)

(global-set-key (kbd "C-c e n") 'eshell-new-buffer)
Magdalenamagdalene answered 17/2, 2023 at 5:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.