2

I'm on Arch Linux (a 32 bits alternative version), and recently I've discovered that the blue lines I used to see in Vim with :set cursorline were supposed to be underlined, and not blue.

That got me searching all around for a solution.

I'm using no graphical environment, so no desktop environment or window manager, only good ol' tty with zsh, my current favorite shell.

I've discovered that :hi CursorLine cterm=bold makes the cursor line a lot prettier, as it's now no longer blue, just a lighter color for the most part, and that's already made my life better.

I also tried cterm=underline (still renders the line blue), undercurl, tried :hi clear CursorLine then doing all over again, but nothing brings me the underlines I want.

I tried Vim on fbterm, because I believe it's a quasi-graphical terminal emulator, but I got the same behavior, only with an uglier super-wide font.

This not only applies to Vim, but to anything, it seems. I tried ANSI escape sequences on echoes, and when trying to underline text, I also got that blue color without underlines.

So I believe something is missing, be it a font, a shell config, a Vim config or whatever.

After searching quite a bit, I got no closer to an answer as to why my tty lacks those formatting options, so I decided to ask here.

It's also worth noting that I tried this on a Raspberry Pi 3B+ running Raspbian, and I got pretty much the same behavior on the tty.

The only place I managed to get that to work was on the X server I start from time to time to use Firefox. I spawned xterm on it and voila I got underlines even while typing commands on zsh.

I'll now try playing around with different terminal fonts to see if I get any closer to prettifying my tty.

Edit 01:

I recorded it with Asciinema, and it shows just fine there, but what I was actually seeing is as I described. asciicast

Edit 02:

I was reading this Arch Wiki page on the section about terminal emulators, and decided to try yaft, as it sounded it could be just the thing I was looking for.

It turned out I already had it installed, and using it does indeed enable at least some of the features I wanted, so that's great.

  • 1
    It's almost certainly capabilities (or a lack of them) in whatever terminal emulator you're using, and/or a mismatched terminal type. What does echo $TERM report, and is it correct? – roaima Nov 20 '19 at 19:43
  • echo $TERM reports linux, and as I'm still using Arch's "default" terminal, I believe it's correct. – Micael Jarniac Nov 20 '19 at 20:07
  • @Christopher, I believe your suggestion is to export TERM=xterm-256color, correct? I've tried that, confirmed it changed with echo $TERM, and still got the blue text instead of underline on both Vim and echo -e "\033[4munderline\033[0m" – Micael Jarniac Nov 20 '19 at 20:39
  • @Christopher well, I was first going to ask it on Stack Overflow, but then realized it was more fit for here. And although this issue does also happen on Raspbian, I first spotted it on my laptop running Arch Linux, so I believe it's more about Linux and the tty than anything else. – Micael Jarniac Nov 20 '19 at 20:54
2

The Linux console driver doesn't support underlines on color displays because it's a compromise between readability and ease of implementation. It's been that way since the mid 1990s, and is documented in console_codes(4):

   4       set underscore (simulated with color on a color display)
           (the colors used to simulate dim or underline are set
           using ESC ] ...)

It's unlikely that you have anything other than a color display. You can change the color used for depicting underline, but it will be colored one way or another. The manual page mentions the escape sequence used to customize the palette:

   ESC ]     OSC      (Should be: Operating system command) ESC ] P
                      nrrggbb: set palette, with parameter given in 7
                      hexadecimal digits after the final P :-(.  Here n
                      is the color (0–15), and rrggbb indicates the
                      red/green/blue values (0–255).  ESC ] R: reset
                      palette

and the escape sequences used to tell which of the 16 palette entries will show dim and underline:

   ESC [ 1 ; n ]       Set color n as the underline color.
   ESC [ 2 ; n ]       Set color n as the dim color.

Setting TERM to any variant of "xterm" will give poor results, because

  • Linux console driver lacks support for things that are found in the xterm terminal description, and
  • the linux terminal description is designed to use the actual features of the Linux console driver.

Use infocmp linux xterm-256color to see the differences. It's long, so here's a summary to show the size of the difference:

$ infocmp -1x linux | wc -l
122
$ infocmp -1x xterm-256color |wc -l
272
$ infocmp -1x linux xterm-256color | wc -l
213
  • Thank you very much! I'll now begin searching for a way to have a terminal (emulator) that works similar to the one I'm used to, but that has a greater set of features. I'll probably end up running an X server with a simple WM just to keep a virtual terminal open, but if that's the way it has to be, then I think it'll be fine. – Micael Jarniac Nov 20 '19 at 23:03

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.