0

Here is how the usual Ubuntu terminal looks when you run the React development serving using npm start and make changes to your source:

ubuntu terminal

Say the server was already running and you tried to do npm start again, you get notified in a colourful message:

enter image description here

And, if you say no, it exits cleanly.

However, I use eshell. This is how the same thing (the react dev. server) looks in eshell: enter image description here

Observe how the output is appended onto the previous contents instead of clearing the screen. The colours are also missing. If the server is already running, this is how the eshell prompt looks like:

enter image description here

This is kind of a mess. Once you say no, it does not exit cleanly but shows the same message again before exiting.

My question is, is there a way to make eshell more like the ubuntu terminal? Is there a modern terminal package for Emacs that could handle these kind of things?

4
  • Eshell is, as its name suggests a shell. Sure, you can add some hacks to handle color escape codes, but you cannot make it handle everything xterm does without turning it into a terminal emulator. It's not a "modern terminal package".
    – wasamasa
    Dec 18, 2019 at 9:45
  • I have forever been confused about the differences between consoles, terminals, cmds, shells, bashes and so forth, To me, they all looked like a command line interface to an operating system. I tried reading at places like this but that only confuses me more. It looks like when you run M x term, it asks to run /bin/bash, Bash according to the link I put before is "the most common shell in modern linux systems", so M x term also runs a shell which is bash, wait what?
    – scribe
    Dec 19, 2019 at 5:20
  • Yes, the terminal emulator runs a program, typically a shell like bash. It doesn't have to though, it might as well run ssh, a serial console, ...
    – wasamasa
    Dec 19, 2019 at 8:31
  • The relationship between a terminal and a shell is much the same as the relationship between a web browser and a web page. A terminal can display many things, but mostly we use it to display the output of a shell like Bash. A web browser can display many things too, but we often use it to display a web page like Stack Exchange.
    – db48x
    May 17, 2020 at 9:44

1 Answer 1

0

FWIW, color handling works out of the box for me with eshell

colortest output

Anything more complicated than that is the task of a terminal emulator, not a shell. Eshell is a replacement for shells, like bash, zsh, you name it, its original purpose was a more familiar environment for developers using Emacs on Windows.

If you want a terminal emulator which runs a shell (like bash or zsh) and handles these escape sequences, your choices are term.el with the M-x term and M-x ansi-term commands and more recently, the vterm package. It might work better for you as it has greater compatibility with xterm (for some reason lots of software in the node.js ecosystem assumes you're using xterm) due to its strategy of letting libvterm handle all the hard work. This means however that you'll need Emacs with dynamic modules support and have to compile the module yourself.

2
  • When I run colortest in /usr/share/emacs/25.2/lisp/eshell, I get: colortest: command not found. Is it because I am on an older version? How can I check the version eshell is on?
    – scribe
    Dec 19, 2019 at 5:35
  • That's a program that's unrelated to Emacs, you'll have to install it separately. Any of the color testing programs will do.
    – wasamasa
    Dec 19, 2019 at 8:31

Your Answer

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

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