Skip to main content
24 events
when toggle format what by license comment
Jul 22 at 22:57 comment added horsey_guy @bvargo This answer is still very useful though.
Oct 18, 2024 at 10:29 comment added einpoklum What is the meaning of "front/back"? What is front and what is back?
Apr 5, 2024 at 14:07 comment added bvargo -1 The answer doesn't use tput or show how it is used. I don't care if the entire world thinks printf is better it still doesn't address the OP's question nor why I ended up here.
Dec 24, 2020 at 12:40 comment added RCross Excellent answer, however I found odd results if passing the zero-padded number returned by fromhex() to tput. Compare echo "$(tput setaf 46)i am green" with echo "$(tput setaf 046)i am green" Changing the printf line to printf '%3d' fixed this.
Jun 15, 2020 at 7:22 comment added Leo Note that even though you don't need to wrap the escapes in \[ \] for printf, you do need to for PS1.
Jun 15, 2020 at 7:02 comment added Leo From trial and error, it seems that 48, as in \e[48;5;???] a special foreground code that unlocks 256 colors and changes the meaning of ;5; to be something other than bilnking for the background. Could someone please point to where that is documented? Ta.
Jan 9, 2020 at 20:56 comment added JdeBP Of course, once "colour schemes" enter the picture, any notion of a standard palette for indexed colour, especially for the 16 aixterm colours, goes completely out of the window. As Thomas Dickey says in another answer, there is no universal colour table, because it depends from the terminal emulator software and from how that software happens to be configured today.
Feb 4, 2018 at 16:25 history edited Jeff Schaller CC BY-SA 3.0
added image titles
Mar 12, 2016 at 22:03 history edited user79743 CC BY-SA 3.0
s/read/red/ typo
Mar 12, 2016 at 21:46 history edited user79743 CC BY-SA 3.0
Added 16 million colors test color line.
Mar 12, 2016 at 21:39 comment added user79743 @StéphaneChazelas Yes, the 16 million color do not work on all consoles (that is the reason for the note I added right from the start). I added now an specific test in red to "see" the (very small) change with that option. The terminal for KDE Konsole does work with 16 million color.
Mar 12, 2016 at 21:35 history edited user79743 CC BY-SA 3.0
added 3016 characters in body
Mar 12, 2016 at 8:49 comment added Stéphane Chazelas Note that at least in my version of xterm the \e[0;%s8;2;%s;%s;%sm doesn't give me 16M colours, just the colour in the 240 colour palette that's closest to the requested rgb.
Mar 12, 2016 at 7:03 comment added user79743 Yes, removing a leading '#' is a reasonable protection. I find a lot simpler to use hex=${1#"#"}. It will remove nothing if $1 does not have a #, and remove it if it exists. See my updated code.
Mar 12, 2016 at 7:01 history edited user79743 CC BY-SA 3.0
Added removal of a leading "#".
Mar 12, 2016 at 5:23 comment added mhulse Lovin’ fromhex. Thanks again! Also, I added a check for the #. Feedback?
Mar 12, 2016 at 5:01 history edited user79743 CC BY-SA 3.0
added 45 characters in body
Mar 12, 2016 at 3:01 vote accept mhulse
Mar 11, 2016 at 15:31 history edited user79743 CC BY-SA 3.0
added 88 characters in body
Mar 11, 2016 at 15:11 history edited user79743 CC BY-SA 3.0
Added conversion from hex colors.
Mar 11, 2016 at 6:45 history edited user79743 CC BY-SA 3.0
Added color names.
Mar 11, 2016 at 6:00 history edited user79743 CC BY-SA 3.0
added 68 characters in body
Mar 11, 2016 at 5:54 history edited user79743 CC BY-SA 3.0
added 68 characters in body
Mar 11, 2016 at 5:44 history answered user79743 CC BY-SA 3.0