top | item 13849128

True Colour support in various terminals

74 points| pmoriarty | 9 years ago |gist.github.com | reply

27 comments

order
[+] est|9 years ago|reply
You know I tried to hack to play a gif upon SSH login, /etc/issue.net does not accept ANSI chars, but /etc/motd does.

So I mkfifo /etc/motd, use some monkey patched shell commands to stream gif to /etc/motd, tried SSH login, the animation totally works, adjust the sleep you get different speeds.

I was totally satisfied with this and logged out of my VPS server. Oh wait....

Since my scripts was not in a loop, so it only feeds data into /etc/motd once, after I logout every SSH session, I can no longer login. Even local login fails because Linux would stuck forever reading the fifo /etc/motd.

I had to mount the disk into another machine and restore /etc/motd to normal.

Lessons learned, don't mkfifo /etc/motd.

[+] toast0|9 years ago|reply
Isn't motd only displayed on interactive login? You could probably have gotten back in if you did something like ssh foo "sudo rm /etc/motd"
[+] Symbiote|9 years ago|reply
I use this fairly often, when working on the image parts of our API (image caching, map tiles etc).

I tweaked the "img" script linked from the article to download and display an image, so I don't need to leave the terminal.

  img http://sipi.usc.edu/database/preview/misc/4.2.03.png
My result is this, in Konsole (KDE): http://i.imgur.com/34fjSas.png
[+] i336_|9 years ago|reply
Sad infodrop: the main reason this is a nonevent is because ncurses encodes fg/bg colors in an unsigned int. :(
[+] GTP|9 years ago|reply
I don't understand the problem, could you please elaborate?
[+] ziotom78|9 years ago|reply
What I think is really interesting in this is not the possibility to use 16 millions colors per se, but rather the ability to directly specify the RGB components of the color to use.

The current approach used by terminfo and ncurses is to refer to an index within a palette, which has the drawback of giving little guarantees about the final shade of the color. (Look at the color table here [1] for a comparison among different terminals; here it is stated that xterm changed the RGB components of two shades of blue from one version to another!)

Allowing true colors in terminals would make curses programming very similar to what you do in HTML and CSS, where you directly specify the color you want. It would surely be a nice improvement.

[1] https://en.m.wikipedia.org/wiki/ANSI_escape_code

[+] chipb|9 years ago|reply
Except you can already query/set the color palette to arbitrary RGB values with control sequences (at least with xterm, rxvt-unicode, and I imagine others).

As far as I've been able to tell, "truecolor" terminal support is about simultaneous display of a range of colors beyond what fits in a palette. Which, eh...seems a bit much for a terminal.

[+] octoploid|9 years ago|reply
Here is an image printing function for bash/zsh:

  function img { for image in "$@"; do convert -thumbnail $(tput cols) "$image" txt:- | awk -F '[)(,]' '!/^#/{gsub(/ /,"");printf"\033[48;2;"$8";"$9";"$10"m "}'; echo -e "\e[0;0m"; done ;}
Example: http://i.imgur.com/d5RzWAC.png
[+] cooper12|9 years ago|reply
Just a note that this requires imagemagick.