Emacs: Terminal vs shell? - shell

I have been reading how to use a shell inside EMACS, along the way I found the concept of Terminal, which is an abstraction for the old physical devices which interacted with the shell.
But, nowadays, I really can't understand which are the advantages regarding its use, so, can you please point me out a couple of situations or examples where one should use it instead of the shell in Emacs?

Running a term buffer is much closer to an actual terminal. Here are a few differences:
Shell mode provides very limited terminal emulation. Programs that take advantage of the terminal's full-screen capabilities (e.g. less, mtr, mutt, top) won't work properly. Terminal mode will generally handle these without any problem.
In shell mode, emacs provides tab completion. In terminal mode, the shell or command-line program provide it themselves.
Shell mode buffers the input and sends it to the process on newline. Terminal mode sends the characters to the running process immediately.
Shell mode works like a regular buffer with the usual emacs key bindings. Terminal mode doesn't intercept most control characters unless you explicitly put it into line mode.

The shell is like another emacs buffer, so the same keys work in it which work in other buffers. It is not true for the terminal.

You can launch the console programs that clear the screen like mc in terminal.

Physical terminals are long obsolete, but the terminal emulators which replaced them are pretty important, and I would presume that most shells outside of Emacs are run within one, so it's not such a mysterious concept to use one within Emacs too.
It's only tangential to your question, but The TTY demystified is an excellent article which you might find enlightening.

Related

Are Command Prompt and PowerShell terminal emulators?

I have read in Codecademy that
To access the command line, we use a terminal emulator, often just
called the terminal.
This gave me the impression that PowerShell and Command Prompt are terminal emulators but when I checked the list of terminal emulators for windows I found the following list in Wikipedia. I would really appreciate it if anyone can help me understand what terminal emulators are, what PowerShell and Command Prompt are, How these things are different. Thank you!
Terminal emulators are applications that emulate the behavior of character-oriented hardware terminals from the early days of computing. For all practical purposes, the Windows Console is an instance of a terminal emulator, as is its modern successor, Windows Terminal.
Typically, the applications that run inside these emulators are interactive shells[1] such as PowerShell and cmd.exe, which act as command-line interpreters, which enable running other applications as well as commands built into those shells and scripts written for those shells.
[1] On Windows, somewhat confusingly, the term shell is also used for the graphical (GUI) shell that provides the Windows desktop and File Explorer. Overall, however, the term shell usually refers to terminal-, character-based shells, such as the POSIX-like shells in the Unix world (a prominent example of which is Bash), and to PowerShell on Windows, as its name implies; while the term conceptually also applies to cmd.exe, historically it hasn't been used much in that context.

Displaying images in an Emacs process running within iTerm2

I want to display inline images in a Emacs process running in iTerm2. Here is a demonstration of what I'm expecting, using imgcat (a iTerm2 shell integration utility).
To begin with, I executed the following code within an *eshell* buffer. The rationale is that if this works out, I can simply setup a separate window dedicated to running eshell, and then update the image with a hook.
imgcat -u https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.png
However, all I got is a bunch of base64 characters, even if I have set TERM to xterm-256color (was dumb).
The reason I chose eshell instead of shell, term, ansi-term or anything else is that it's implemented in Emacs Lisp, so it should be the most extensible one. On the other hand, using other terminal emulators is also OK if you find them more handy.

Are there any terminals that have fully customizable keybinds?

Reason being is that I use emacs-nox, meaning the text-editor program runs inside the terminal.
And many of my binds conflict with the terminal keybinds (such as Ctrl+i)
So are there any terminals out there that allow for any given command signal to be turned off.
Yes indeed there is.
Most definitely.
xterm

How to stop MATLAB from opening a new window using Cygwin?

In the past, I have used MATLAB sparingly from Linux machines at work, and I far and away preferred using the '-nodesktop' option. On all Unix-like machines I've worked on this option allows me to control STDIN and STOUT with relative ease, but on Windows(using Cygwin) this option spawns a new window and control is returned to the calling shell!
Basically, I would like to know if there is any way that I can force MATLAB to behave as it would on a Unix-like machine?
Thanks!
Short answer: You can not.
A longer answer can be found on their website.
-nodesktop behaves differently depending if you are on Windows vs
Linux or Mac. On Windows we provide a boring Command-Window only
interface that lacks the “bells and whistles” of the regular Command
Window or the full Desktop.
So you can use -nodesktop, but it pops up that annoying command line only window.

Is there any way to prevent ncurses based programs from running?

Hey there, I'm building a remote shell server that interfaces between a text-only client and a virtual shell.
It works perfectly when using regular shell commands, but the first thing that people try after that is vim, which promptly drives my server crazy and can't even be closed remotely.
Is there any way to detect ncurses based programs and prevent them from running in my special shell?
(the server is ruby, but any system command will do)
You can declare the capabilities your shell has, by setting the TERM environment variable to the correct value. For instance, if your shell has the same capabilities as the vt100 terminal, export TERM to the correct value, and programs like vim will respect that.
To run vim in vt100-mode, try:
TERM=vt100 vim
You could also try:
export TERM=dumb
The trick is to find a terminal that corresponds to the capabilities of what you are creating. There is a lot to choose from. On my system (Arch Linux) this gives me a long list of choices:
find /usr/share/terminfo
You might be able to find a terminal specification that corresponds to what your program can handle.
Alternatively, you may want to consider implementing terminal emulation for ansi or vt100:
http://en.wikipedia.org/wiki/ANSI_escape_code
http://www.termsys.demon.co.uk/vtansi.htm
Best of luck!

Resources