Irssi — How to use it in a comfortable way?

Irssi is an IRC client program for Linux, FreeBSD, macOS and Microsoft Windows. It was originally written by Timo Sirainen, and released under the terms of the GNU GPL-2.0-or-later in January 1999.

Irssi — How to use it in a comfortable way? — Article Preview

📓 The name ‘Irssi’ (IRC in Finnish) is a bit weird and I often spell it wrongly. So, I normally make a alias to it. For example, alias ichat=irssi to make it easy to remember and spell.

Install

> sudo pacman -S irssi

📓 Check download page for installation guide on different Linux distributions or Windows.

Start

When start Irssi, you will probably see the same terminal interface like below one which is quite crude.

You can see the same terminal interface only when you see start irssi for first time. After /quit , it will create ~/.irssi/config automatically. Then, when you start it again, the terminal interface will be a bit different — simpler.

Setup

Before we can do anything with Irssi, we must setup it — configure servers providing IRC service.

As the welcome screen showing, we can get lots of commands by typing /HELP command:

07:11 Irssi commands:
07:11 accept die knock notice sconnect unload
07:11 action disconnect knockout notify script unnotify
07:11 admin echo lastlog op scrollback unquery
07:11 alias eval layout oper server unsilence
07:11 away exec links part servlist upgrade
07:11 ban flushbuffer list ping set uptime
07:11 beep foreach load query sethost userhost
07:11 bind format log quit silence ver
07:11 cat hash lusers quote squery version
07:11 cd help map rawlog squit voice
07:11 channel hilight me recode stats wait
07:11 clear ignore mircdcc reconnect statusbar wall
07:11 completion info mode redraw time wallops
07:11 connect invite motd rehash toggle who
07:11 ctcp ircnet msg reload topic whois
07:11 cycle ison names resize trace whowas
07:11 dcc join nctcp restart ts window
07:11 dehilight kick netsplit rmreconns unalias
07:11 deop kickban network rmrejoins unban
07:11 devoice kill nick save unignore

It will definitely a time consuming work to learn each of them. We can also check official site document page to get startup.

Let’s see the most important command connect which will help us to connect to specified network or server. We can type /help connect to get detailed usage. There are quite a few arguments need to pass to connect command. To make the connection secure, we need to have -tls being used.

By checking the official document of specified server, we can manage to get easy-to-use commands to setup connection.

Steps to setup secure connection to LiberaChat server:

Run below commands in terminal shell:

openssl req -x509 -new -newkey rsa:4096 -sha256 -days 1096 -nodes -out libera.pem -keyout libera.pem
...
mkdir -p ~/.irssi/certs && cp libera.pem ~/.irssi/certs
  • Add server with certificate and then connect

Run below commands in irssi one by one:

/server add -tls_cert ~/.irssi/certs/libera.pem -network LiberaChat irc.libera.chat 6697
/connect irc.libera.chat

⚠️ Here, the command is /connect irc.libera.chat rather than /connect LiberaChat which will fail with message Irssi: Unable to connect server LiberaChat port 6667 [Name or service not known]. To make the command /connect LiberaChat workable, we need to add the network by /network add LiberaChat unless you can see it by /network list by default.

Till now, if everything goes well, you will see the messages like below which proved that the connection has been setup successfully:

Irssi — Connect to LiberaChat with Certificate

Join Channels and Start Talking

Now, you can join any channels to start ask and answer questions there. For example, to join #bash channel by typing /join #bash and you will see a long list of nicknames followed by below messages:

07:57 -!- Irssi: #bash: Total of 772 nicks [0 ops, 0 halfops, 0 voices, 772 normal]
07:57 -!- Channel #bash created Wed May 19 14:13:50 2021
07:57 -!- Irssi: Join to #bash was synced in 0 secs

Now, say hello to others. You will see your nickname before the message:

07:57 < wenijine1> hello

This nickname is kind of variant of your username in system, if you haven’t register the nickname or the nickname has been registered by others. To register nickname, you need to check IRC network/server documentation. For example, here is the link to register nickname on LiberaChat.

After registration, you can identify your nickname in irssi:

/msg NickServ IDENTIFY YourNick YourPassword

Then, you will see:

08:39 -NickServ(NickServ@services.libera.chat)- You are now identified for wenijinew.
08:39 -NickServ(NickServ@services.libera.chat)- Last login from: ~wenijinew@c83-248-21-105.bredband.tele2.se on Dec 30 07:04:57 2021 +0000.

If you were identified, then it will say:

08:39 -NickServ(services@services.joseon.kr)- You are already identified.

💁 You need to switch to different windows by shortcut Alt + < or Alt + > to see messages belong to different window. For example, in channel #bash window, you cannot see any message printed by NickServ as it’s in the window nickserv . And help commands output normally in status window.

Use SASL

To identify nickname every time is kind of boring thing. SASL(Simple Authentication and Security Layer) is a method that allows identification to services (NickServ) during the connection process, before anything else happens — therefore eliminating the need to /msg NickServ identify.

LiberaChat official documentation give instructions about how to do SASL.

If you configure SASL when you add network, then the command is:

/network add -sasl_username <login> -sasl_password <password> -sasl_mechanism PLAIN LiberaChat

If you already added the network, then you will use modify command:

/network modify -sasl_username <login> -sasl_password <password> -sasl_mechanism PLAIN LiberaChat

After that, you can save the configuration and quite irssi :

/save
/quit

Then, re-start irssi and reconnect to server:

/connect liberachat

You will see similar messages with below ones:

08:58 -!- wenijine1!wenijinew@c83-248-21-105.bredband.tele2.se wenijinew You are now logged in as wenijinew
08:58 -!- SASL authentication succeeded

And when you check ~/.irssi/config file, you will find content like below:

LiberaChat = {
type = "IRC";
sasl_mechanism = "PLAIN";
sasl_username = "wenijinew";
sasl_password = "[YOUR PASSWORD IN PLAIN TEXT HERE]";
};

Maybe you already noticed, it’s not good to use PLAIN SASL mechanism as your password is in plain text which is too bad from security point of view. To avoid this, we need to switch authentication to certificate from password.

SASL with Certificate

To use SASL with certificate (to allow NickServ recognize you based on your certificate), we need to add the sha512 fingerprint to the account. Before that, we need to connect to server with password (as we did in last section).

/connect LiberaChat

After connection, we can check the client certificate by whois command:

/whois wenijinew
22:56 [LiberaChat] -!- wenijinew [~wenijinew@c83-248-21-105.bredband.tele2.se]
22:56 [LiberaChat] -!- ircname : Unknown
22:56 [LiberaChat] -!- server : tungsten.libera.chat [Umeå, SE]
22:56 [LiberaChat] -!- : is using a secure connection [TLSv1.3, TLS_AES_256_GCM_SHA384]
22:56 [LiberaChat] -!- : has client certificate fingerprint
62c210da9dcdc6580db886cdb31f07107666e0005227ff08ef26987b418ad9e0027ce6cc4a9102cd299a2add61c6237873aed1d46ee5cee6edfb054c1d27e9ac
22:56 [LiberaChat] -!- hostname : 83.248.21.105
22:56 [LiberaChat] -!- idle : 0 days 0 hours 5 mins 27 secs [signon: Sat Jan 1 08:05:35 2022]
22:56 [LiberaChat] -!- account : wenijinew
22:56 [LiberaChat] -!- End of WHOIS

Then authorize the certificate fingerprint by /msg NickServ CERT ADD command. We can see the command result in nickserv window:

22:51 <wenijinew> CERT ADD
22:51 -NickServ(NickServ@services.libera.chat)- Added fingerprint
62c210da9dcdc6580db886cdb31f07107666e0005227ff08ef26987b418ad9e0027ce6cc4a9102cd299a2add61c6237873aed1d46ee5cee6edfb054c1d27e9ac to your fingerprint list.

Then, we can switch the authentication to certificate:

/disconnect LiberaChat
/network modify -sasl_password '' -sasl_mechanism EXTERNAL LiberaChat
/connect LiberaChat

After that, your PLAIN password is removed from ~/.irssi/config file:

LiberaChat = {                                                                                                                                                                                type = "IRC";
sasl_mechanism = "EXTERNAL";
sasl_username = "wenijinew";
};

Till now, we finished important step to setup secure connection (based on TLS certificate) to LiberaChat server.

irc.libera.chat      6697  LiberaChat tls, tls_cert: ~/.irssi/certs/libera.pem

Next step is also important: we want to auto-connect server and auto-join specified channels when we start irssi .

Auto-Connection + Auto-Join

To enable auto-connection to server, we can do modification on server configuration: (add the option -auto)

/server modify -network LiberaChat -auto irc.libera.chat 6697

To enable auto-join channel, we can add or modify channels. For example, to add #bash channel fromLiberaChat network and enable auto join:

/channel add -auto #bash LiberaChat

As we want to have the channel #bash being automatically joined, we do /save to save the configuration to the physical config file — we can see below line in ~/.irssi/config file in channels section:

{ name = “#bash”; chatnet = “LiberaChat”; autojoin = “yes”; },

Now, we finish all basic setup work for irssi client. Next step, we want to make the crude interface a bit colorful like below one: (it’s mine and you can find more from http://irssi-import.github.io/themes/ created by others. One of most popular irssi themes is: https://github.com/ronilaukkarinen/weed)

Irssi: Customized Theme

Customize the Theme

Here, we will do some very basic customization based on default.theme — automatically created in ~/.irssi/default.theme when you do /save in irssi for the first time. For now, the file default.theme is the start point for us to learn how to customize irssi theme. In old version, maybe people start from /format or /usr/share/doc/irssi/formats.txt file which is the core file we learn how to use color or format text in irssi theme.

By checking ~/.irssi/default.theme and /usr/share/doc/irssi/formats.txt , we can do basic customization.

To keep the default theme as a reference, we can create a new theme file and config it in ~/.irssi/config file:

319 settings = {
320 core = {
321 real_name = “‘Bruce Wen’”;
322 user_name = “wenijinew”;
323 nick = “wenijinew”;
324 };
325 “fe-text” = { actlist_sort = “refnum”; };
326 “fe-common/core” = { theme = “wenijinew”; };
327 };

After config file change, we can reload it in irssi session:

[(status)] /reload

And it will print one message:

10:02 -!- Irssi: Reloaded configuration

Some basic concepts in Irssi’s formats and themes:

Irssi’s colors:

%k %K %0 represents black text, dark grey text and black background. Here, %k, %K, and %0 are Irssi’s language. It should be like place holder which is to be repalced with concrete color code when it renders terminal interface for text and background. Check /usr/share/doc/irssi/formats.txt file for more definitions of Irssi’s colors. Note: (1) %n is used to reset previously configured color and %N is for default color. (2) %ZAABBCC is to support HTML color in hex notation like #AABBCC in HTML code.

MIRC color:

The format file /usr/share/doc/irssi/formats.txt defined a list of MIRC color code and usage. MIRC color codes can be used when sending message. It can be disabled by hide_colors=ON in

Format codes:

Except for colors, Irssi also defined placeholders for formats such as bold(%9 or %_), underline(%U), italic(%I).

Here are a few examples to customize irssi color and format:

  • foreground(fg) or textcolor: color the default foreground(fg) color: default_color = "-1" , -1 is the ‘default terminal color’ and the available value depends on the terminal color mode. If it’s 256 color terminal, then we can use all values from 0 to 255: 0 is the pure black and 255 is the pure white. For 255 colors, check https://www.ditig.com/256-colors-cheat-sheet or similar web page. 📓Here, you cannot use the text format like ‘%r’ for red text. It only accepts numbers. In fact, this will define the value of ‘%N’ — default color.
  • timestamp: color the timestamp in green: timestamp = "%g$*%n"%g means green color, $* means whole text of timestamp, %n means reset color back to the one it was in higher template (previously used color, here it’s default color). Note: %n should be used as ending for all format configurations as we don’t want to apply the format to all.
  • own nickname: by default, it’s ownnick="%_$*%n"; and I would like to use yellow color for my nickname to distinguish from others: ownnick="%_%y$*%n";
  • own message: this is necessary because you want to distinguish your own message to others. I use green color for my message: ownmsgnick="%Y{msgnick $0 $1-%Y}%g . Here, msgnick is another templace to define what and how your nickname is displayed before message, As you noticed, I used yellow color for my msgnick . And here is the msgnick template: msgnick="%K<%n$0$1-%K>%n %|"; which used <> surrounds the nick mode ($0) and nickname ($1), and finally it used %| for the indentation position.
  • join/quit messages: if you don’t want the join/quit messages bothering you, you can hide them by configuring ignores = ( { level = "JOINS PARTS QUITS"; } ); in ~/.irssi/config file. Of course, you can also customize the color used for join/quit messages in theme file. I used green color for join and red color for quit: channick_hilight = "%G$*%n"; chanhost_hilight = "{nickhost %G$*%n}"; channick = "%G$*%n"; chanhost = "{nickhost} %R$*%n";
  • status bar: like other terminal applications, status bar of Irssi also one important place to put kinds of helpful information. Default color of status bar is white foreground and blue background: sb_background="%4%w"; and my customized color is yellow foreground and red background (Chinese favorite color): sb_background="%Y%z360000"; . Here, the key is sb_background but it can give both foreground and background color, which is a bit confused. By default, statusbar shows window information. The items in the statusbar can be shown by command statusbar window . The items could be added and removed. All configurations about statusbar can be found in ~/.irssi/config file, the statusbar section.

Till now, I think it’s good enough to have one confortable Irssi settings. I wish you can get helpful information in this article and start to config your Irssi and then talk to developers in channels. Trust me, you can get lots of powerful support there. Later on, I will record one video to show my own Irssi and how did I use it.

Thanks for reading and happy coding!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store