multi-term
updated Whenever it makes sense, I try to use emacs for my computer-based activities; surely, programs like The Gimp or a graphical web browser cannot yet be replace by emacs, but I'm making progress. I like the ways emacs gives me to automate and speed-up my tasks; I get some return-on-time-investment.
2010 or not, I still spend quite a bit of time on the console. So why not do that from within emacs? There different ways to run shells within emacs.
The simplest one is shell
(i.e,, M-x shell
), which starts a simple shell,
which does not support which does not support 'graphical' console applications,
such as mutt
, mc
, htop
.
Then there are term
and ansi-term
(M-x ansi-term
) that do support such
applications, which ansi-term
supporting colors as well (it seems to have
become the default for term
in recent emacs versions).
Another one is the nifty EShell (included with emacs), which is not just a
(simple) terminal, but also a full shell environment, and has integration with
other things in emacs. It's nice, but has some of the limitations that shell
has - you cannot run 'graphical' applications; also, I don't really need a
shell, as I am quite happy with zsh (zed shell) already, which is more
powerful, and I prefer a shell that works both inside and outside emacs.
For all these reasons, I am using MultiTerm, which has 'graphical' support that
ansi-term
has, but adds a nice extra, namely support for multiple terminals
within emacs. I'm not fully up to date with the exact difference in the terminal
support between the two, but I haven't had any problems so far.
You can install multi-term
(put it in your load-path
), and add the
following to your .emacs
:
(autoload 'multi-term "multi-term" nil t) (autoload 'multi-term-next "multi-term" nil t) (setq multi-term-program "/bin/bash") ;; use bash ;; (setq multi-term-program "/bin/zsh") ;; or use zsh... ;; only needed if you use autopair (add-hook 'term-mode-hook #'(lambda () (setq autopair-dont-activate t))) (global-set-key (kbd "C-c t") 'multi-term-next) (global-set-key (kbd "C-c T") 'multi-term) ;; create a new one
With this, C-c t
will jump through your multi-term
buffers (create a new one
if it doesn not exist yet), while C-c T
unconditionally creates a new
terminal.
9 comments:
Actually the only difference between term and ansi-term is that ansi-term uses ansi colors - other than that they are identical. multi-term is actually mostly the same as term, adding a couple of extensions for handling several terminals at once. I'd probably have tried it if it wasn't for the horrible English of it's principle author Andy Stewart - I simply have hard time imagining that you can write quality software without having a decent command of English(I'm not a native speaker, but good command of English is nowadays essential in the area of software development).
A quote from the ansi-term page in Emacs Wiki - "I think MultiTerm is more better." – AndyStewart :-)
Fun part aside - I still think there are none decent solutions to the "terminal emulator for Emacs problem". nterm(http://kanis.fr/nterm.html) is one of the few promising projects in the area with a clean codebase, instead of reusing term for the nth time, but the author says that the project is far from a stable release and he lacks the time needed to refine it.
P.S. I dare you to have a look at http://code.google.com/p/emacs-nav/ and maybe drop a line or two about it if you like it :-)
I use shell-mode and have been really happy with it. It doesn't do well running anything complicated like mutt, but it does act a little more like a normal buffer than the term modes.
MultiTerm does look nice since I'm pretty sure part of the reason for not using the term modes is because I couldn't have more than one.
As always, great post!
I think you can use screen command within one multi-term session.
Ctl-A-A to toggle different screen session branches and ctl-A-C to start a new screen session.
@Bozhidar: good point; it seems I mixed up 'term' and 'shell', updated the post, thanks.
I actually appreciate Andy Stewart's (many!) contributions, no matter how good or bad his English.
I tried nterm a few years ago, but it did not work very well for me; maybe I should retry. And I'll take a look at nav, thanks.
One advantage of Eshell is that it will work everywhere Emacs runs.
You might wanna check out conkeror (conkeror.org) if you're looking for an emacs style web browser.
@docgnome: now that you mention it, I'm actually a quite happy conkeror user; I plan to writing something about for e-fu.
I see a lot of comments on various emacs threads about using multi-term for the ability to establish more than one terminal buffer. I simply save (C-x C-w) the term or shell buffer with a unique name, then open a new term or shell buffer, as many as I want. Each buffer I save has the remote hostname as the filename since I typically ssh to a server from within the term buffer. That way, I also get a log of everything I've done in that term buffer. When bringing up the buffer list with C-x C-b, the term buffers show "Term" as the mode. Multi-term has a Ctrl-key combination to switch between terminals. Other than that, what am I missing here by not using multi-term?
Post a Comment