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?

  • 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 '19 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 '19 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 '19 at 8:31
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.

|improve this answer|||||
  • 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 '19 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 '19 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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