8

I'm searching for a method to write a text with different colors like I always saw on other IRC channels. I want to achieve this with Irssi which is CLI based. I have found multiple methods which didn't work as expected. How can I for example write

WHAT

with green color for example?

I would like to achieve the same effect from a simple Bash script too.

2
  • see e.g wikipedia Commented Mar 15, 2014 at 20:12
  • yes i already done that but it's not working maybe you could give an example? maybe i'm doing wrong something
    – rsz
    Commented Mar 15, 2014 at 20:25

1 Answer 1

11

First, make sure to enable text colors with

/set hide_colors OFF

Within Irssi, to answer your concrete question, type

Ctrl+C 3 WHAT

and then Enter. The text will show up in green. This convention is known as mIRC colour codes. To make it more comfortable, download the colour_popup script, place it in your ~/.irssi/scripts/autorun folder and run this command:

/statusbar prompt add -after input -alignment right colours

Then it will show you the available colours once you type Ctrl + C.

On the other hand with Bash, you need to use ANSI colour codes. To output green text, try this command:

printf "\e[%dm%s\e[m\n" 32 hallo

\e[ is a CSI (terminal control sequence start) and m is the command; it means character graphics attributes like colour, bold, ...

3 refers to the dull foreground colour table, 2 is green; valid colours go from 0-7. Bright colours are 90-97; background colours are 40-47 and 100-107. There are even more colours possible with other encodings, such as 256 colour table "38;5;<idx>" where <idx> is from 0-255, or 24 bit RGB colours "38;2;12;34;56" (12/255 red, 34/255 green, 56/255 blue); this is not supported by all terminals.

4
  • 1
    It's probably worth mentioning how to enable text colors in the first place. Some Linux distros disable them in the default config. Since apparently you haven't logged in since January, I've taken the liberty to just edit that in into your answer.
    – Staven
    Commented Oct 17, 2015 at 9:49
  • @Staven /set hide_colors OFF doesn't seem to work. I can see it on the outgoing messages, but not incoming messages. Any idea how to fix this? Commented Nov 15, 2015 at 4:02
  • This did not work for me in PuTTY on Windows. When I press Ctrl+C, irssi displays a C in reverse colors in my input window, and when I press "3" it just adds a 3 to the input buffer as usual. Any tips? Commented Aug 25, 2016 at 0:28
  • @DavidGrayson it is shown like that only when composing. After pressing Ctrl+C, a C in reverse colors will be displayed on your input window, and after adding a "3", it is simply added to the input buffer as usual. Then append the text you want in green, eg. "hello world" and send it (you may want to use an empty channel or /query yourself for these tests). When viewed in the channel, a green "hello world" will be displayed (actually, the Ctrl+C and 3 are sent on the wire, but parsed by the irc clients for determining how to display).
    – Ángel
    Commented Oct 26, 2016 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.