I want to change the shape of the cursor in my various (emulated) terminals.

The shape that I want is ⼕ (sorry if it doesn't render). It's a three sided box that opens to the right. This way I could see where insertions are, and also see which character the cursor is "on". I found that character in Unicode at U+2F15.

I definitely want to be able to do this both in the kernel virtual terminals of Linux (i.e. what one gets with Control+Alt+FN) and in GUI terminal emulators like (say) XTerm and RXVT. If possible, I want to do this even in network terminals like (say) PuTTY and KiTTY. If I cannot get that exact character, I'd like at least that three-line shape.

I understand that this will involve either "ANSI" escape codes or (perhaps) settings in the terminal emulator (although given that that will not apply to the Linux built-in terminal emulator this is not preferable). Please provide an answer that is not dependent from using any particular shell. Is this even possible without altering the kernel code?

  • What distinction are you drawing between "the terminal" and "the TTY"? Because whatever wild misunderstanding it is, it isn't the strictly accurate distinction that TTYs are terminals that were made by the Teletype Corporation. If you are talking about a distinction between full-screen TUI terminal emulators (e.g. the one built into Linux) and GUI terminal emulators using X (e.g. Unicode RXVT), those are not the words to use. – JdeBP Jun 22 '20 at 17:39
  • I use TTY when not in GUI, and terminal emulator for specifically in GUI. I use terminal for both, but usually for GUI. I haven't used TUI, and I've only seen others use it once or twice. I use shell for the interaction (bash, fish, etc), and I don't use console anywhere. – Not me Jun 22 '20 at 22:54
  • That is definitely not the way to use "TTY", and people won't read this question as asking about the thing that you are asking about. – JdeBP Jun 23 '20 at 10:28
  • How would you have me use it for this question? – Not me Jun 23 '20 at 13:52
  • See unix.stackexchange.com/questions/55423/… – Garo Jun 29 '20 at 15:00

The shapes for cursors that are available in virtual terminals and real terminals are limited. Generally, they only enable setting shapes that match old display hardware, which usually only permitted specifying a blink cycle and a starting and an ending scanline for when the cursor was gated on, sometimes only a very limited subset of start+end combinations (e.g. underline, overline, half-height, block).

The two major control sequences for this are DECSCUSR and LINUXSCUSR. DECSCUSR is DEC's name for the control sequence that DEC supported in its later range of terminals. Like other manufacturers of real terminals, in its doco DEC gave its vendor-private control sequences names that began "DEC". (In its doco, Tektronix used the "TEK" prefix for naming its vendor-private control sequences, for comparison.) The Linux doco is quite poor, as usual, and doesn't name stuff. So "LINUXCUSR" is my coinage, with a "LINUX" prefix by analogy.

Neither DECSCUSR nor LINUXSCUSR are standardized. They are different from each other, but they were invented at roughly the same time (only appearing for the DEC VT 5xx in the 1990s) so there wasn't the usual years of DEC prior art. ☺ Egmont Koblinger has commented elsewhere that the model of both is underwhelming, as it conflates blinking with shape. There also has been some discussion of changing the meaning of DECSCUSR 0 to enable user-specified shapes. And Microsoft Terminal has highlighted the mismatch between the DECSCUSR model and the model used in the Win32 console mechanism, which has allowed arbitrary start lines for three decades (four decades if one accounts for its predecessors in the VIO subsystem of OS/2 1.x and the PC/AT video firmware).

The upshot is that there isn't a single control sequence that will work universally, the world currently dividing into DECSCUSR and LINUXSCUSR camps, because almost no terminal emulator supports both. Moreover, with these two you do not have anywhere near the flexibility that you want. The only widespread deviation from the start+end scanline model is a vertical bar, and that you only get with some GUI terminal emulators (e.g. XTerm), which have added one additional shape as DECSCUSR 5 and DECSCUSR 6.

Yes, you could modify the code of the FreeBSD kernel, NetBSD kernel, OpenBSD kernel, and Linux built-in terminal emulators, and of the various application-mode terminal emulators (framebuffer and X11 GUI) to do more cursor shapes. It would be quite tough to make it universal, though.

I've done this in my terminal emulator. DECSCUSR 7/8 are an outline box. DECSCUSR 9/10 are a star. DECSCUSR 11/12 are underline+overline. DECSCUSR 13/14 are a reversed "L" shape. I've been thinking, based upon reading some old 1970s literature, of adding two orientations of square brackets and overline-only. But DECSCUSR does not readily lend itself to the sort of arbitrary specification of actual Unicode characters that you are looking for. LINUXSCUSR does not match that idea at all, moreover.

Further reading

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.