Who in their right mind is using IRC in 2021? Seems like it’s still quite popular at least in some circles. Think of it as Slack for open-source projects. And if you need some help or want to contribute to some open source projects it’s quite often the fastest means of communications.
There are many great Linux IRC clients, however today I’m going to be going over how to setup weechat with tmux (terminal multiplexer). This combination will allow you to have a persistent IRC session that you can attach / detach from.
WTF do I need a terminal multiplexer for you may be asking yourself. Well you don’t “need” one, but it is convenient, even if you are just running weechat locally. However it’s even more useful if you are running it remotely on a VPS / Server or Cloud box.
Why is it useful? If you want your connection to be persistent, even after “closing” your terminal by accident. Or rebooting your local machine, the IRC connection can remain persistent (assuming your server or VPS remains online).
This also allows you to re-connect to your session from anywhere in the world from other computers or phones (anything that would support terminal sessions really).
This is the abomination of an init system that we’ll use to startup our tmux’d weechat sessions at server startup, since it’s present in most of the modern Linux distributions.
Above we’ve covered the moving parts that we’ll be configuring here. SystemD is likely already installed on whatever distro your using. Below are the commands you can use to install weechat and tmux if you need a hand with that.
apt install weechat tmux
pacman -S weechat tmux
Now we will create our user systemd service that we will need to enable on our server/VPS for startup.
Add the following to ~/.config/systemd/user/weechat.service (you will likely have to create this directory if it doesn’t exist).
[Unit] Description=Weechat with tmux [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/tmux -2 new-session -d -s irc /usr/bin/weechat ExecStop=/usr/bin/tmux kill-session -t irc [Install] WantedBy=default.target
Once created, you will need to enable and start the service. And you can do that with the following commands.
sudo loginctl enable-linger $(whoami) systemctl --user enable weechat systemctl --user start weechat
Finally you can check on it to make sure everything’s OK with the following command:
systemctl --user status weechat
Now it may say (exited) there, but that’s just cause the process is backgrounded. You should now be able to connect to your tmux session.
Locally you can connect with the following command:
tmux attach -t irc
You can then use ctrl-b d to detach the session.
If you are on a remote host, and you have SSH access you can connect with the following command:
ssh <yourserver> -t tmux attach -t irc