WeeChat – hide buffers below servers


Today I received a message from a user (Fearful). He was asking if there is a way to hide the buffers below the servers in the buffers bar.

I finally found out a way to achieve this. Here how it works:

You middle-click on an item in the buffers bar. For example the channel #weechat. Then you press ‘h’ to hide channels and privates buffers and keep only the server buffer. So we need to bind something to “middle-click + h” combo:

/key bindctxt cursor @item(buffers):h /command -buffer ${full_name} irc /allchan -current buffer hide;/command -buffer ${full_name} irc /allpv -current buffer hide;/cursor stop

then, to unhide those buffers we will press “middle-click + H (uppercase)”

/key bindctxt cursor @item(buffers):H /command -buffer ${full_name} irc /allchan -current buffer unhide;/command -buffer ${full_name} irc /allpv -current buffer unhide;/cursor stop

To hide all buffers from all servers, middle-click on the weechat core buffer.

You dont even need to unmerge servers buffers from core. It works in both case.

Thanks Fearful for this excellent idea!

WeeChat – Buffers Bar Whitelist


Yesterday, I decided to unmerge the servers buffers from the core. Why? Because it is a lot easier on the eyes. Anyway, I use the mouse with WeeChat so I do not have to alt+j # to change buffer. The only thing I will miss is the CTRL+x to switch between merged buffer.

In the following image, the left side is merged with core and the right side is not merged (independant):


Then, I looked up at the options and found an interesting one, the whitelist.

The whitelist

The whitelist allow you to set a different color scheme for certain buffers. The idea that came to my mind was “it would be nice to set a backgroup color for the core and the servers”. Well there is an option named


This option will put the specified color as the background color of the core, the servers, the plugins (highmon,chanmon…). The problem with this option is that the background color you want will be removed whenever a low, private, message or highlight is received. You will need to click the name of the server then it will be back to the desired color. The solution? You put the name of the core and all servers in the following option:


Mine looks like this:

/set buffers.look.whitelist_buffers "server.UnderNet,server.TripSit,server.OFTC,server.NetChat,server.freenode,server.EFNet,server.DivinityCoding,server.DaIRC,server.BitlBee"

then you need to put the desired color in these options:

/set buffers.color.whitelist_default_bg 31
/set buffers.color.whitelist_highlight_bg 31
/set buffers.color.whitelist_low_bg 31
/set buffers.color.whitelist_message_bg 31
/set buffers.color.whitelist_private_bg 31

For the foreground colors I could have kept the defaults, or the same values as I chose for the main scheme. But I decided to adjust the colors to fit the background color.

here is my main scheme

/set buffers.color.hotlist_message_fg 229
/set buffers.color.hotlist_private_fg 121
/set buffers.color.hotlist_highlight_fg 163

and here is my whitelist scheme

/set buffers.color.whitelist_highlight_fg 198
/set buffers.color.whitelist_message_fg 221
/set buffers.color.whitelist_private_fg 83

The following options:

/set buffers.color.current_fg 31
/set buffers.color.current_bg white

set the colors for the current buffer no matters the scheme.

Now I like my buffers bar :)

WeeChat – Auto KickBan

If you press the middle mouse button on a nick in the nicklist and then press the ‘b’ key, you will ban the user with the default mask (option irc.network.ban_mask_default). By default, it is:


I replace mine with:


This is fine but I would prefer to add them in a auto kickban list. There is no way to obtain the host when we press the ‘b’ key (only the nick). A solution is to use the perlexec.pl script. So we will modify the bind for the ‘b’ key. First, install the script:

/script install perlexec.pl

then type this:

/key bindctxt cursor @item(buffer_nicklist):b /window ${_window_number};/who ${nick};/wait 2s /perlexec my $infolist=weechat::infolist_get("irc_nick", "", '${server},${channel},${nick}')\;weechat::infolist_next($infolist)\;my $hostname = (split("@", weechat::infolist_string($infolist, "host")))[1]\;weechat::command("", '/trigger addreplace auto_kb_${server}_${channel}_${nick}_${date:%Y_%m_%d_%H_%M_%S} signal ${server},irc_in_join "\\${channel} =~ ${channel} && \\${host} =~ ' . $hostname . '" "" "/quote -server ${server} MODE ${channel} +b *!*@' . $hostname . '\;/command -buffer irc.${server}.${channel} irc /kick ${channel} ${nick} bye bye" "ok"')\;weechat::command("", '/kickban ${channel} ${nick} bye bye')\;weechat::infolist_free($infolist);/cursor stop

This create a new trigger that exec two commands when a user in the auto kickban list joins the channel:

/quote -server ${server} MODE ${channel} +b *!*@$hostname
/command -buffer irc.${server}.${channel} irc /kick ${channel} ${nick} bye bye

you may ask “why not use /kickban instead”. I tried with /kickban but this ban the nick only. I don’t know why. So instead I send a raw mode message. You may also ask why you use /command instead of /kick directly. If you use /kick directly you will get this message:

irc: command "kick" must be executed on irc buffer (server or channel)

Then after created the trigger, we kickban the user. /kickban works here.

/kickban ${channel} ${nick} bye bye"

If you prefer to add the hostname to the autoban list of the X bot (undernet) and ChanServ (freenode, oftc, …) you could type:

/key bindctxt cursor @item(buffer_nicklist):b /window ${_window_number};/who ${nick};/wait 2s /perlexec my $infolist=weechat::infolist_get("irc_nick", "", '${server},${channel},${nick}')\;weechat::infolist_next($infolist)\;my $hostname = (split("@", weechat::infolist_string($infolist, "host")))[1]\;weechat::command("", ('${server}' eq "undernet") ? '/msg -server ${server} x@channels.undernet.org ban ${channel} *!*@' . $hostname . ' 100d 300 bye bye' : '/msg -server ${server} chanserv@services. akick ${channel} add *!*@' . $hostname . ' !P bye bye | Default ban');/cursor stop

This way we don’t need any trigger!

I use the second bind. I prefer to add the people to the services bot ban list. This is more powerful.

If you prefer to keep the default bind for ‘b’, you could create a ‘B’ bind. This way, you could use ‘b’ to ban someone only temporary or use ‘B’ to add him to the auto kickban list.

Now I’m ready to control my channel more accurately. As fast as a graphical IRC client!