A look at terminal emulators, part 1
lwn.net
lwn.net
Last time I compared terminals re:Unicode, I settled on sakura (over xterm, urxvt, st, xfce4-terminal at least). I should probably try mlterm too, but since I don't understand any RTL languages myself, I actually find it less confusing if they are "backwards", especially when they occur in the middle of non-RTL strings. https://opensource.com/life/16/3/twisted-road-right-left-lan... is a scary look at the possibilities for misinterpretation – keeping everything in byte order at least makes it predictable and unambiguous, though "wrong".
-----
By the way, `set enable-bracketed-paste on` really should be default, that's an instant productivity enhancer! I used to think it was impossible to paste tabs into the terminal …
The article itself has an example of this. It contains RTL language which should not be right aligned because it properly belongs in line with the rest of the text. How is a terminal suppose to know this without the application telling it. The application is the one with knowledge of the context.
I took a leaf out of the book of dealing with octal escapes in string literals in the C language. One of the simplest ways of avoiding the problem of the octal number in the escape being followed by an actual intended digit character is to terminate the string literal and start a new one. Hence:
"abcde\001""23"
I took the same idea and applied it to pasted content. When console-terminal-emulator receives ESC or CSI characters from its input FIFO that are marked as pasted text, immediately after sending them on it sends an end-of-paste sequence (DECFNK 201) followed by a start-of-paste (DECFNK 200). Thus any potential DECFNK control sequence in the pasted text, that would otherwise itself turn pasting on and off, is broken up.* http://jdebp.eu./Softwares/nosh/guide/console-terminal-emula...
For example: Generating the sequence ESC [ 2 0 1 ~ l s LF as pasted input directly to the terminal emulator's input, in the way that a realizer program would send pasted input events, with
# printf '%c\x00\x00\x09' $'\x1B' '[' 2 0 1 '~' 'l' 's' $'\n' >> /run/dev/vc2/input
results in user virtual terminal #2 receiving the following % printf "\x1b[?2004h" ; cat -v
^[[200~^[^[[201~^[[200~[201~ls
Breaking that down, those are:1. DECFNK 200 (start pasted text mode)
2. ESC (as pasted character)
3. DECFNK 201 (end pasted text mode)
4. DECFNK 200 (start pasted text mode)
5. [ (as pasted character)
6. 2 (as pasted character)
7. 0 (as pasted character)
8. 1 (as pasted character)
9. ~ (as pasted character)
A. l (as pasted character)
B. s (as pasted character)
C. LF (as pasted character)
A Z shell running in that terminal does indeed receive this as the pasted text ESC [ 2 0 1 ~ l s LF, exactly as sent, and does not enact the embedded end-of-paste or Line Feed.
[autocompletion plugin] https://github.com/zsh-users/zsh-autosuggestions
.Xdefaults-localhost
*VT100.Translations: #override \
Shift<Key>Return: string("shift return")\n\
Ctrl<Key>Return: string("ctrl return")\n\
Alt<Key>Return: string("alt return")\n\
Super<Key>Return: string("super return")
Here are the escape sequences used by Kitty for sending modifiers to the shell from the terminal: https://github.com/kovidgoyal/kitty/blob/master/protocol-ext... (thanks aumerle)Don't let them do the differentiation them.
Hook a script/something between the keyboard and the terminal that does it for them.
On the contrary, many (perhaps even most) of them can. This is a matter of having a keyboard map that makes these into two distinguishable actions. For many terminal (emulators, at least) this is indeed entirely within the remit of the keyboard map and not limited by the terminal emulator itself at all.
Easy to find example: The us.kbd keyboard map on FreeBSD, used by the terminal emulator that is built in to the kernel and that provides the kernel virtual terminals, distinguishes between these two chords, mapping the former to CR and the latter to LF.
/usr/share/vt/keymaps % sed -n -e '3,5p;/089/p' us.kbd
# scan cntrl alt alt cntrl lock
# code base shift cntrl shift alt shift cntrl shift state
# ------------------------------------------------------------------
089 cr cr nl nl cr cr nl nl O
/usr/share/vt/keymaps %
Note that to take advantage of a mapping like this, one has to turn off the crnl input mode in the terminal line discipline. Again, though, the kernel line discipline is a separate thing to the terminal emulator and this is not a mechanism of the terminal emulator.I tried it out and it doesn't work in zsh, because pasted lines of code always get expanded for you to inspect before they're executed.
Most people will instinctively just press Enter after pasting though, which will defeat the expansion's utility.
It deals fine with Unicode. It's not as functional or fully-featured as Konsole, but it's good enough. It has real tab support (urxvt supports tabs through a Perl extension but in a somewhat convoluted way) and doesn't use GTK3.
Another nice feature of Qterm is support for font ligatures, like the ones provided in Fira Code.
I currently use sakura (a lighter fork of gnome-terminal less the gnome stuff). I'm mostly just after something that's minimal, the first thing I do when trying out a new terminal emulator is turn off all of the GUI fluff (I use a tiling window manager), then it's all down to font rendering, speed and small binary footprint. I can at least get qterminal down to the actual text console so far which is a good start :) (many terminals you can't)
Konsole does this, and I'd be fairly surprised if qterminal didn't, either -- but if you're concerned about this, you should definitely check the source code.
It's not available on Linux, but iTerm2 does this!
Though there is still lots of trickery that can sneak into text, e.g. zero-width characters, and I’m trying to come up with better filters.
Incidentally, when you say iTerm2 "does this" do you mean the simple "confirm paste" behavior, or does it actually explicitly protect against the bracketed paste mode attack?
I even tried 'rxvt-unicode-with-perl-with-unicode3-with-plugins-9.22' from Nix, which includes colour support, to the same results.
http://www.pleyades.net/david/projects/sakura
One of many that wraps libvte - but it's pretty small, and does everything I need.
I use it with the font size set larger.
xtermfont: -fixed----20-
Some of the fancier terminals I have tried had key bindings that interfere with applications I use. It was enough of a hassle I prefer to just stick with plain old xterm.
I use terminator for the iTerm2 like splits on Linux.
It does appear to be included though?
I believe that these products are also optimized for allowing non-technical staff to use old 'greenscreen' terminal UI applications. These products usually have features like macros for commonly-used sequences of key-combos, and they also do things like figuring out if the screen is showing a menu, and turning the menu entries into something that can be clicked by a mouse so it isn't entirely keyboard driven.
For a dev and/or ops person on a modern Linux system, there's almost certainly no reason to look into this stuff.
x3270 (http://x3270.bgp.nu/) handles one of the most popular of those.