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.

mbac32768
  • 11,453
  • 9
  • 34
  • 40

8 Answers8

14

You can do this:

`C-u M-x eshell`

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

Chris R
  • 17,546
  • 23
  • 105
  • 172
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.

pajato0
  • 3,628
  • 3
  • 31
  • 37
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.

Sean
  • 29,130
  • 4
  • 80
  • 105
1

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

Community
  • 1
  • 1
Jeevan Pingali
  • 1,072
  • 1
  • 9
  • 11
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))
Aborn Jiang
  • 981
  • 10
  • 9
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))))
Community
  • 1
  • 1
Nick
  • 167
  • 3
  • 9
0

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

konr
  • 2,545
  • 2
  • 20
  • 38
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)
Raveen Kumar
  • 71
  • 1
  • 10