Hacker News new | ask | show | jobs
by chriswarbo 2128 days ago
I use Emacs shell-mode for most of my terminals, which allows navigating and editing the buffer just like any other file. I'll often make several copies of a command, then use a macro to alter each one; after checking that they look right, pressing Enter will send them all to the shell.
1 comments

I always tried to use the shell with emacs (eshell, multi-term) but it didn't render correctly curses and all the fancy stuffs like emojis. Out of curiosity, how do you manage that?
Check out emacs-libvterm. I’ve replaced all terminal emulators with it. All the benefits of an Emacs buffer and no issues with curses or lag.
When I used Emacs, Eshell was perhaps my favorite feature. I loved how modern it felt in many ways; why shouldn’t you be able to just `cd` into a remote location (TRAMP+SSH under the hood), or invoke Elisp commands like Magit straight from the shell. It could however be quite slow, and choked on some common escape codes (e.g. the progress bars emitted by the modern Ubuntu `apt` command.)

Regarding curses, I found that there was two solutions. The first is to automatically spawn curses apps in a proper terminal emulator, you just have to setup the `visual-commands` variable properly. The second alternative is to replace curses apps with Emacs apps, e.g. htop to helm-top. Personally, I ended up going the second route after a while, as I realized that there are actually very few curses apps that are important to me, and that Emacs apps are better integrated if you use Emacs for everything else.

If you rely on a lot of curses apps, a “real” terminal like emacs-libvterm may however suit you better. Renders curses apps and emojis as well as any other terminal I’ve used. It’s also much faster than ansi-term and friends at rendering.

I use a separate terminal (st) for curses-like things. They work in Emacs ansi-term, but since that doesn't offer the same navigation/editing interface as normal Emacs buffers I don't find it compelling enough to use.

Eshell is interesting, but I can't use the bashisms I'm used to, and I can't copy commands back-and-forth between the prompt and a standalone script.

shell-mode lives in-between these two extremes: it runs a normal shell, but Emacs manages the buffer. I don't know about ansi-term or eshell (or alternatives mentioned by others), but shell-mode handles emoji fine, as well as progress bars and colour codes; I think it defaults to TERM=dumb, so many programs won't output colour, etc. unless you override it to something like TERM=xterm-256.

Usually with ansi-term instead, if I'm honest. Also look into emojify-mode if your system doesn't handle emoji fonts well or at all.
Belatedly to add - look into the eshell-visual-* lists, to configure commands, subcommands (like "git log"), and I think some other traits, such that matching commands get their own ansi-term buffer.