Emulate A Terminal, in a region, in a buffer and in Eshell
Find a file
2024-03-15 01:32:41 +06:00
integration Add message passing support 2023-09-17 21:58:40 +06:00
term * term/eat.el: New file. 2022-12-04 12:52:36 +06:00
terminfo * eat.ti (eat-mono): Remove unused capability 'Ed' 2023-10-19 00:12:25 +06:00
.dir-locals.el Rename prompt mode to line mode and generalize it 2023-09-23 02:15:45 +06:00
.elpaignore * .elpaignore: New file. 2022-11-28 01:10:14 +06:00
.gitignore ; * .gitignore: Ignore 'dir' and 'eat.info' 2022-12-17 11:24:02 +06:00
ChangeLog ; Release version 0.9.4 2023-12-15 22:27:53 +06:00
CONTRIBUTE Fix Makefile 2023-10-08 12:55:05 +06:00
COPYING Implement the terminal 2022-11-24 14:26:03 +06:00
eat-tests.el Update tests to make them pass 2023-10-07 16:31:16 +06:00
eat.el ; eat.el (eat-default-shell,eat-tramp-shells): Fix 2024-02-04 10:45:45 +06:00
eat.texi * eat.texi (Top): Add "Sixel" to table of contents 2024-03-15 01:32:41 +06:00
eat.ti * eat.ti (eat-mono): Remove unused capability 'Ed' 2023-10-19 00:12:25 +06:00
fdl.texi Implement the terminal 2022-11-24 14:26:03 +06:00
gitlog-to-changelog ; Ignore a commit while generating ChangeLog 2022-11-29 16:18:35 +06:00
gpl.texi Implement the terminal 2022-11-24 14:26:03 +06:00
make-changelog ; Write copyright year range properly in ChangeLog 2022-11-30 17:27:44 +06:00
Makefile Fix Makefile 2023-10-08 12:55:05 +06:00
NEWS Implement the terminal 2022-11-24 14:26:03 +06:00
README.org ; README.org: Fix wrong keybinding 2023-11-08 23:41:31 +06:00
texinfo.tex Implement the terminal 2022-11-24 14:26:03 +06:00

Eat: Emulate A Terminal

Eat's name self-explanatory, it stands for "Emulate A Terminal". Eat is a terminal emulator. It can run most (if not all) full-screen terminal programs, including Emacs.

It is pretty fast, more than three times faster than Term, despite being implemented entirely in Emacs Lisp. So fast that you can comfortably run Emacs inside Eat, or even use your Emacs as a terminal multiplexer.

It has many features that other Emacs terminal emulator still don't have, for example Sixel support, complete mouse support, shell integration, etc.

It flickers less than other Emacs terminal emulator, so you get more performance and a smoother experience.

To get the most out of Eat, you should also setup shell integration.

Usage

To start Eat, run M-x eat. Eat has four input modes:

  • "semi-char" mode: This is the default input mode. Most keys are bound to send the key to the terminal, except the following keys: C-\, C-c, C-x, C-g, C-h, C-M-c, C-u, C-q, M-x, M-:, M-!, M-& and some other keys (see the user option eat-semi-char-non-bound-keys for the complete list). The following special keybinding are available:

    • C-q: Send next key to the terminal.
    • C-y: Like `yank', but send the text to the terminal.
    • M-y: Like `yank-pop', but send the text to the terminal.
    • C-c C-k: Kill process.
    • C-c C-e: Switch to "emacs" input mode.
    • C-c M-d: Switch to "char" input mode.
    • C-c C-l: Switch to "line" input mode.
  • "emacs" mode: No special keybinding, except the following:

    • C-c C-j: Switch to "semi-char" input mode.
    • C-c M-d: Switch to "char" input mode.
    • C-c C-l: Switch to "line" input mode.
    • C-c C-k: Kill process.
  • "char" mode: All supported keys are bound to send the key to the terminal, except C-M-m or M-RET, which is bound to switch to "semi-char" input mode.
  • "line" mode: Similar to Comint, Shell mode and Term line mode. In this input mode, terminal input is sent one line at once, and you can edit input line using the usual Emacs commands.

    • C-c C-e: Switch to "emacs" input mode
    • C-c C-j: Switch to "semi-char" input mode.
    • C-c M-d: Switch to "char" input mode.

If you like Eshell, then there is a good news for you. Eat integrates with Eshell. Eat has two global minor modes for Eshell:

  • eat-eshell-visual-command-mode: Run visual commands with Eat instead of Term.
  • eat-eshell-mode: Run Eat inside Eshell. After enabling this, you can run full-screen terminal programs directly in Eshell. You have the above input modes here too, except line mode and that C-c C-k is not special (i.e. not bound by Eat) in "emacs" mode and "line" mode.

You can add any of these to eshell-load-hook like the following:

;; For `eat-eshell-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-mode)

;; For `eat-eshell-visual-command-mode'.
(add-hook 'eshell-load-hook #'eat-eshell-visual-command-mode)

To setup shell integration for GNU Bash, put the following at the end of your .bashrc:

[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && \
  source "$EAT_SHELL_INTEGRATION_DIR/bash"

For Zsh, put the following in your .zshrc:

[ -n "$EAT_SHELL_INTEGRATION_DIR" ] && \
  source "$EAT_SHELL_INTEGRATION_DIR/zsh"

There's a Info manual available with much more information, which can be accessed with C-h i m Eat, also available here on the internet.

Installation

Eat requires at least Emacs 26.1 or above.

NonGNU ELPA

Eat is available on NonGNU ELPA. So you can just do M-x package-install RET eat RET.

If you're on Emacs 27 or earlier, you'll need to add NonGNU ELPA to your package-archives by putting the following in your init.el:

(add-to-list 'package-archives
             '("nongnu" . "https://elpa.nongnu.org/nongnu/"))

Quelpa

(quelpa '(eat :fetcher git
              :url "https://codeberg.org/akib/emacs-eat"
              :files ("*.el" ("term" "term/*.el") "*.texi"
                      "*.ti" ("terminfo/e" "terminfo/e/*")
                      ("terminfo/65" "terminfo/65/*")
                      ("integration" "integration/*")
                      (:exclude ".dir-locals.el" "*-tests.el"))))

Straight.el

(straight-use-package
 '(eat :type git
       :host codeberg
       :repo "akib/emacs-eat"
       :files ("*.el" ("term" "term/*.el") "*.texi"
               "*.ti" ("terminfo/e" "terminfo/e/*")
               ("terminfo/65" "terminfo/65/*")
               ("integration" "integration/*")
               (:exclude ".dir-locals.el" "*-tests.el"))))

Manual

Clone the repository and put it in your load-path.

Comparison With Other Terminal Emulators

Term

Term is the Emacs built-in terminal emulator. Its terminal emulation is pretty good too. But it's slow. It is so slow that Eat can beat native-compiled Term even without byte-compilation, and when Eat is byte-compiled, Eat is more than three times fast. Also, Term flickers, just try to run emacs -nw in it. It doesn't support remote connections, for example over Tramp. However, it's builtin from the early days of Emacs, while Eat needs atleast Emacs 26.1.

Vterm

Vterm is powered by a C library, libvterm. For this reason, it can process huge amount of text quickly. It is about 1.5 times faster than Eat (byte-compiled or native-compiled) (and about 2.75 faster then Eat without byte-compilation). But it doesn't have a char mode (however you can make a char mode by putting some effort). And it too flickers like Term, so despite being much faster that Eat, it seems to be slow. If you need your terminal to handle huge bursts (megabytes) of data, you should use Vterm.

Coterm + Shell

Coterm adds terminal emulation to Shell mode. Although the terminal Coterm emulates is same as Term, it is much faster, about three times, just a bit slow than Eat. However, it too flickers like other terminals. Since it's an upgrade to Shell, you get all the features of Shell like "line" mode, completion using your favorite completion UI (Company, Corfu, etc), etc. Most of these features are available in Eat, and also in Eat-Eshell-Mode as Eshell is similar to Shell, however it's not Shell mode. Recommended if you like Shell.

Acknowledgements

This wouldn't have been possible if the following awesome softwares didn't exist: