Emacs: shell vs eshell vs term

By Xah Lee. Date: . Last updated: .

Difference between shell, term, eshell

Emacs has many shell commands. Here's their differences:

Alt+x shell

Start the standard emacs interface to Operating System's command line interface. [see Emacs: Run Shell]

Alt+x eshell

A shell written entirely in emacs lisp. Note: it is not a bash emulator. Eshell is a shell by itself, but similar to bash or other shells. [see Emacs: eshell]

Alt+x term

Start the terminal emulator in emacs. It behaves like a dedicated terminal app.

It is compatible to more shell apps than emacs shell interface, but standard emacs keys such as moving cursor doesn't work here.

Alt+x ansi-term

Pretty much same to term today. It always start a new buffer.

emacs shell vs eshell 2024-07-05
emacs shell vs eshell 2024-07-05

Which shell command to use?

It depends on your preference and needs. The following is a general guide.

shell is the most popular. It is good for general use of classic/standard unix shell commands, e.g. {grep, du, ls, sort, cat, head, tail, uname}. [see Linux: Basic Shell Commands]

term and ansi-term are good if you want to run stuff like ssh, or other command line interactive interface (such as {python, ruby} shell), or text based GUI app such as vim.

eshell is good especially on Microsoft Windows where bash is not installed. Eshell is also super fast on startup. If you are a emacs lisp programer, you might prefer eshell because direct access to emacs lisp and better integration with emacs.

Personally, i used shell from 1998 to 2013, and eshell since 2013. But i always have a real terminal app open, for running any command i'm not familiar with. For any serious command, such as starting a server, or any command that has logs, i run it in a real terminal app, with no tie to emacs.

Shell in Emacs