Hanging around in IRC is fun. However, when you don’t stay connected all the time (why do you shut down your computer anywaysâ€Ś) you are missing out a lot of that fun! This is obviously an unbearable state, this needs immediate fixing!
Persistent IRC Setup
There are several ways of building a persistent IRC-setup. One is a so called bouncer that works like a proxy that mediates between you and the IRC network and buffers the messages. Another, simpler method is just running a IRC-client on a machine that is always powered on, like a server, that we can reconnect to to read our messages (and of course write new ones).
- A computer that is powered and connected to the internet 24⁄7
- an account on said machine that is accessible via SSH
- Software installed on said machine: tmux, weechat
Alternatively to tmux, screen can be used if you cannot get tmux installed on the machine you want to run this setup on, it works very similar. This post, however, will focus on the tmux-setup.
We can access our account via
We should end up in a plain terminal prompt where we can type.
In this shell we can then start
weechat, a fully keyboard-controlled terminal-IRC-client.
Adding a server
To add a server, type
/server add <servername> <serveraddress> -ssl -autoconnect
-autoconnect are both optional.
-ssl will enable encryption to the IRC network by default,
-autoconnect will enable autoconnect in the server config, so that our weechat will automatically connect to that server when we start it.
<servername> will be the weechat-internal name for this server,
<serveraddress> can also include a port by appending it via
Adding the freenode-network could therefore read
/server add freenode chat.freenode.net/6697 -ssl -autoconnect
Afterwards, we can connect to the freenode-network by issuing
as the autoconnect only works upon starting of weechat.
/quit weechat and start it again we should get autoconnected.
And now, we are connected to the freenode-network!
Setting your name
By default, our nick will be set according to our username on the system. It can be changed via
To change it persistently, we can set the corresponding option in weechat via
/set irc.server.<servername>.nicks "demodude"
to a custom nickname.
Generally, options in weechat can be set by
/set <optionname> <value> or read by
Weechat also supports globbing in the optionname, so getting all options for our added server can be done by
Communication on IRC happens in channels. Each channel usually has a certain focus of stuff that happens there. We can then join channels via
which is a very boring channel as no one except for ChanServ and us is here, which you can see on the user list for this channel on the right. But it technically worked and we can now just type to post messages in this channel.
In the bar right above where we type we see a
Weechat has the concept of buffers.
Each buffer represends one server or channel.
The channel we are in is now buffer 2.
To get back to our server-buffer, we can type
/buffer 1 or hit
F5, both will bring us back to buffer 1, which is our server-buffer.
To get back to our channel-buffer,
/buffer <buffernumber> or
F6 will bring you there.
To enter channels on a server upon starting weechat, we can set the option
irc.server.<servername>.autojoin, to a comma-separated list of channels
To find all the channels on a IRC-server, we can issue a
/list (for freenode, be aware, the list is HUGE).
We can save our changes via
/save and exit weechat via
We can scroll backward and forward by using the
If we are at the very bottom of a buffer, weechat will automatically scroll down with incoming messages.
If you have scrolled up, weechat will not follow as it assumes you want to read the part you scrolled to.
- adding server:
/server add <servername> <serveraddress>[/<port>] [-ssl] [-autoconnect]
- connecting to a server:
- joining channels:
- switching buffers:
- leaving channels:
We are up and running for IRC now! However, once we exit our weechat, we are no longer connected and missing out all the fun! So our weechat needs to run continuously.
Usually, upon SSH-disconnect, all of our processes will be killed (including our weechat). This is different with tmux. Tmux allows to reattach to what we have done when last SSH-ing into our server.
So we exit our weechat and are back on our shell. There, we start
We now see a green bar at the bottom ouf our screen.
This is a tmux and a shell running inside of it.
We can now hit
Ctrl+b to tell tmux to await a tmux-command and not forward our typing to the shell but instead interpret it as a command to tmux itself.
We can then type
d to detach and our shell is gone.
Afterwards, we can reattach to our tmux by running
tmux attach and our shell is back!
This also works when we detach and then log out of our machine, log in again and then reattach our tmux.
Now the only thing left is running a weechat inside of our tmux and we are done. We can detach (or just close the terminal, also works perfectly fine) and then reattach later to read what we have been missing out on. Our persistent IRC-setup is ready to rumble.
Improving our setup
Up to now we have a running setup for persistent IRC. However, the user-experience of this setup can be significantly improved.
Weechat is capable of tab completion, e.g. when using /set.
However, by default, weechat autocompletes the first option it finds fully instead of to the first
., which is the configsection-delimiter in weechat.
To change this, we search for completion options via
and afterwards we
/set weechat.completion.partial_completion_command on /set weechat.completion.partial_completion_command_arg on /set weechat.completion.partial_completion_completion_other on
Weechat is a highly extendable software. A full list of extensions can be found here, some of the most useful ones are listed in the following.
You can install all scripts directly from within weechat via
/script install <scriptname>
buffers.plprovides a visual list of open buffers on the left side of weechat (from weechat 1.8 onwards this can be replaced by weechat’s built-in buflist, which provides the same feature)
beep.pltriggers our terminal bell when we are highlighted, mentioned or queried
autojoin_on_invite.pydoes basically what the name says
screen_away.pywill detect when we detach from our IRC-setup and report “I’m not here” to the other person if one is queried
autosort.pykeeps your buffers sorted alphabetically, no matter how many you have open
autosort.py you most likely also want to
/set buffers.look.indenting on /set irc.look.server_buffer independent
To automate reattaching to tmux every time you SSH into the machine your persistent IRC-setup is running on, we can put
if [[ $TERM != 'screen' ]] then tmux attach || tmux fi
at the end of the file
getting a shell besides your weechat
You can also open more shells in tmux.
To do so, hit
Ctrl+b and then ‘c’ for create.
You will find another buffer (not the weechat-buffer, but the concept in tmux is equivalent) down in your tmux-bar.
The buffers read
You can then switch between buffers via
FUO (frequently used options)
A lot of IRC-network allow registration of usernames to ensure that we can reuse our nick and no one else grabs it. If we have done that, Weechat can automatically identify us upon connecting. To do so, we just need to set the password we chose when registering in the option
However, we just need to be aware that weechat saves that password in plaintext in the configuration.
Weechat can also trigger arbitrary commands when connecting to a server. This is useful for things like self-invites into invite-only-channels or other things that you want to trigger. To use this, we just need to set
to a semicolon-separated list of commands as you would issue them manually in weechat.