Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open multiple terminals?

Tags:

emacs

In Emacs, I often find myself in a situation where I need to jump back and forth between various source files to various terminals. However, I feel like I do not have a good way to do this efficiently and it's clumsy that you can only open one shell in Emacs (shell, eshell, or term).

Moreover, I need an efficient way of juggle between multiple terminals and source files.

How can I achieve this?

like image 590
Bain Markev Avatar asked Oct 22 '10 02:10

Bain Markev


People also ask

How do I open multiple terminals at once?

CTRL + Shift + N will open a new terminal window if you are already working in the terminal, alternatively you can just select "Open Terminal" form the file menu as well. And like @Alex said you can open a new tab by pressing CTRL + Shift + T .

How do I open multiple terminals in virtualbox?

We can switch between virtual terminals in Virtualbox with CTRL+ALT+FX.

How do I open multiple terminals in putty?

In Putty Settings > Window > Behavior, you can check one of the boxes to open the system menu on a certain keypress (I personally use ALT-Space). With this setting in place, you can hit ALT-Space, then type the d key to Duplicate Session.

How do I open multiple terminals on a Mac?

Press Command-N. Choose Shell > New Window > New Window with Profile. The name of the profile that opens is concatenated to the end of the New Window with Profile menu item.


1 Answers

You can have as many terminals and shells open at once as you want. Just use M-x rename-buffer to change the name of an existing *term* or *shell* buffer, and the next time you do M-x term or M-x shell, a brand new buffer will be created. In the case of M-x shell, a prefix argument will cause you to be prompted for the name of the new shell buffer, as offby1 noted.

A few years ago I had a job where I had to regularly log in to various production servers named "host01.foo.com", "host02.foo.com", etc. I wrote a little function like this one to make it easier to manage them all:

(defun ssh-to-host (num)   (interactive "P")   (let* ((buffer-name (format "*host%02d*" num))          (buffer (get-buffer buffer-name)))     (if buffer         (switch-to-buffer buffer)       (term "/bin/bash")       (term-send-string        (get-buffer-process (rename-buffer buffer-name))        (format "ssh host%02d.foo.com\r" num))))) 

Then I bound this command to (say) s-h (super H), enabling me to just type M-5 s-h. If I didn't already have a buffer named *host05*, it would start a new terminal emulator buffer, rename it to *host05*, and ssh me into host05.foo.com. If buffer *host05* already existed, it would simply switch me to it. Quite handy!

like image 177
Sean Avatar answered Sep 21 '22 06:09

Sean