Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I write colored text to irc channel with Irssi?

Tags:

irc

irssi

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.

like image 493
rsz Avatar asked Mar 15 '14 20:03

rsz


1 Answers

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.

like image 186
Nei Avatar answered Oct 18 '22 22:10

Nei