Emacs as your terminal

There are four decent options for running a terminal or shell from within Emacs. Doom offers a module for each. They are:

  • :term eshell
  • :term shell
  • :term term
  • :term vterm

But which one do you choose?

Eshell

eshell is a native shell – implemented completely in Emacs Lisp. It’s stable, works anywhere Emacs runs (on any OS), and has no external dependencies, but lacks features you’ll expect from mature shells, tends to be slower than them in some cases, and does not support command line tools with TUIs (e.g. curses, ncdu, nmtui, top, etc).

Eshell would be perfect if you didn’t have to reinvent all the wheels in the dealership.

Shell

shell is a REPL for your shell, rather than a terminal emulator. You can edit your command line like you would any ordinary text in Emacs – something you can’t do in term (without term-line-mode, which can be unstable) or vterm.

Due to shell's simplicity, you’re less likely to encounter edge cases (e.g. against your shell config), but it’s also the least capable. TUI programs like htop or vim won’t work in shell directly, but will be launched in a term buffer – which handles them reasonably well.

Term (ansi-term)

term is Emacs’ built-in terminal emulator. It understands many (but not all) terminal escape codes, so many TUI programs (like top or vim) will work, but its performance is inferior to standalone terminals, especially with large bursts of output.

Unless term-line-mode is enabled (automatically activated when evil users switch to normal mode), you can’t modify your command line like you would a normal text buffer. Even in line mode it can be a little buggy.

vterm (emacs-libvterm)

vterm is as good as terminal emulation gets in Emacs (at the time of writing) and the most performant, as it is implemented in C. However, it requires extra steps to set up:

  • Emacs must be built with dynamic modules support
  • You’ll need to compile vterm-module.so, which has external dependencies (libvterm, cmake and libtool-bin).

vterm will try to automatically build vterm-module.so when you first open it, but this will fail on Windows, NixOS and Guix out of the box. Install instructions for nix/guix can be found in the :term vterm module’s documentation. There is no way to install vterm on Windows that I’m aware of (but perhaps with WSL?).

I still can’t decide

eshell and vterm are generally the best choices. shell is a decent alternative for Windows users.

2 Likes

There is no way to install vterm on Windows that I’m aware of (but perhaps with WSL?).

It does indeed work as intended inside WSL, and is probably what we should recommend overall for windows.

1 Like