In Emacs I can run a shell using following commands –
M-x term
M-x shell
M-x eshell
What is the difference between these three?
emacsshell
In Emacs I can run a shell using following commands –
M-x term
M-x shell
M-x eshell
What is the difference between these three?
Best Answer
shell
is the oldest of these 3 choices. It uses Emacs'scomint-mode
to run a subshell (e.g.bash
). In this mode, you're using Emacs to edit a command line. The subprocess doesn't see any input until you press Enter. Emacs is acting like a dumb terminal. It does support color codes, but not things like moving the cursor around, so you can't run curses-based applications.term
is a terminal emulator written in Emacs Lisp. In this mode, the keys you press are sent directly to the subprocess; you're using whatever line editing capabilities the shell presents, not Emacs's. It also allows you to run programs that use advanced terminal capabilities like cursor movement (e.g. you could runnano
orless
inside Emacs).eshell
is a shell implemented directly in Emacs Lisp. You're not runningbash
or any other shell as a subprocess. As a result, the syntax is not quite the same asbash
orsh
. It allows things like redirecting the output of a process directly to an Emacs buffer (tryecho hello >#<buffer results>
).