7

Would it be possible to download a GUI version of Emacs which includes its own terminal emulator for any terminal-related commands like executing shell scripts? I.e., it would not use the local system's terminal but would include its own sandboxed terminal.

0

2 Answers 2

13

Yes, there are many, and several of them come with Emacs. Which you will prefer depends on your precise needs.

shell and eshell will both give you shells with no terminal–emulation at all. shell runs your normal shell, while eshell runs a shell made entirely in Emacs lisp, with better integration with the Emacs internals (for example, you can redirect the output of a command to an Emacs buffer, as well as to a file).

term will let you run a shell (or any other program) inside a terminal emulator. The one downside here is that most Emacs keybindings are altered while in this mode, so that you can operate ordinary programs that expect a wide variety of inputs.

If you are willing to install packages, then vterm is a good one. The terminal emulation is compiled into a loadable module rather than being written in Emacs lisp, so it is faster.

You will want to read chapter 38 Running Shell Commands from Emacs in the Emacs manual for more information about shell, eshell, term and a few other related topics. You can also read the Emacs manual, and potentially many others, while inside of Emacs. Use C-h i to open the Info viewer; it starts you out at an index of all available manuals.

5
  • Oh yea, I’d forgotten about that.
    – db48x
    Sep 14, 2021 at 22:44
  • Thank you. A few follow-up questions: Is "shell" a command? eshell runs a shell made entirely in Emacs lisp. How does this shell differ from bash? Is it given an internal filesystem? What packages can or cannot be installed into it? Does it use commands like ls, cd, or completely different commands? I'll read the docs now. Thank you Sep 15, 2021 at 8:03
  • Yes. You can run it with M-x shell. Same with the others.
    – db48x
    Sep 15, 2021 at 18:08
  • @JohnSmith : how does the eshell differ from bash? It does for example not support the type command and the $PS1 variable for prompt string customization. The ls command is supported in eshell and works like in bash. which ls states: 'eshell/ls is a byte-compiled Lisp function in ‘em-ls.el’.` If you try to get a list of all available commands in eshell using compgen -c you will see that there is no compgen command in eshell. If you run info ls in eshell you will get the info help on ls command from coreutils, not info help on the eshell ls.
    – Claudio
    Mar 27, 2023 at 11:17
  • @JohnSmith: if you want info or man about eshell ls use ls --help. This will give you help on the in elisp implemented eshell ls command. Notice that: This command is implemented in Lisp. If an unrecognized option is passed to this command, the external version ‘/usr/bin/ls’ will be called instead.
    – Claudio
    Mar 27, 2023 at 11:23
3

In addition to the built-in option @db48x said, there are some third-party terminal emulator packages for Emacs.

If you like the idea of Shell, you can check out Coterm. It emulates a terminal emulator in Shell.

As @db48x said, Vterm is also an option if you have no problem installing C modules.

There is new option named Eat. It is pretty new to the list. In addition to M-x eat, it can also emulate terminal in Eshell. It has complete mouse support, and shell integration like VSCodium (or VSCode) is also available. [Disclaimer: I'm the author.]

All the options also work when Emacs is run in terminal.

2
  • 1
    Came here because when I saw a package called "eat" in list-packages I just had to know what it actually did, and then I ended up trying to search recent discussions of terminal emulators in emacs to see if eat was the new best game in town now. Anyway, +1, both for the terminal and for posting an answer that highlights the relevant differences. Do you know if any of those support the new terminal graphics protocol, and do you have plans to support it if you don't already?
    – mtraceur
    Mar 26, 2023 at 5:09
  • 1
    @mtraceur No, Eat doesn't support Kitty's terminal graphics protocol, and I'm not aware of any Emacs terminal emulator that supports graphics. Implementing a graphics protocol in Eat is on my wish list, but unfortunately right now I'm too busy to work on a new feature. Mar 27, 2023 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.