Weechat Stuff

Weechat Stuff

Some people I know asked me to write a little bit about the IRC client I use, weechat, and how I have it set up and customized. So here we are. ๐Ÿ˜

The basics…

To start, weechat is a terminal based IRC client. No pretty GUIs I’m afraid. If you really must have a GUI. I suggest trying HexChat, KVIRC, or mIRC. If you’re not even sure what IRC is, you should probably start with this. I’m going to assume that if you’re here, you know what IRC is and at least a bit of how to use weechat already.

Scripts

Scripts make weechat even better. And as it happens, weechat has a really good scripting system. Instead of writing some proprietary scripting language, it just uses scripting languages available on most *nix systems, like perl, python, lua, ruby, etc… So, if you know a scripting language already, chances are you can use it with weechat. Anyway, I use the following scripts:

autosort.py
highmon.pl
grep.py
autojoin.py
colorize_nicks.py
buddylist.pl
buffer_autoset.py
bufsave.py
bufsize.py
cron.py
go.py
kiloseconds.py
listbuffer.py
log.py
maskmatch.py
mass_hl_blocker.pl
pybuffer.py
topicdiff.py
typing_counter.py
unwanted_msg.py
urlserver.py
whois_on_query.py

I also used to use buffers.pl to give myself a nice buffer list, but that’s been rolled into the client itself with the buflist plugin since version 1.8.

Settings

Various settings I use. I’m only going to list the ones that are different than the default value.

/set buflist.format.buffer = "${if:${buffer.number}==${buffer.next_buffer.number} || ${buffer.number}==${buffer.prev_buffer.number}?${color:white}โ™ป: }${format_number}${indent}${format_nick_prefix}${if:${buffer.type}==1||${plugin}==python||${type}==0||${type}==server?${color:245}:${color_hotlist}}${format_name}${format_hotlist}

This is mostly to replicate the look and functionality I had set up using buffers.pl.


/set buflist.format.buffer_current "${color:,blue}${if:${buffer.number}==${buffer.next_buffer.number} || ${buffer.number}==${buffer.prev_buffer.number}?${color:white}โ™ป: }${format_number}${indent}${format_nick_prefix}${color_hotlist}${format_name}"

Same with this one.


/set buflist.look.mouse_move_buffer = "off"
/set buflist.look.mouse_wheel = "off"

Because I don’t use the mouse with weechat. YMMV.


/set buflist.look.nick_prefix = "on"

Because I like nicks with hats.


/set irc.color.nick_prefixes = "q:lightred;a:lightcyan;o:lightgreen;h:lightmagenta;v:yellow;*:lightblue"

Set some colors for the various mode prefixes.


/set irc.look.color_nicks_in_nicklist = "on"

So I can have pretty nicklists too.


/set weechat.bar.status.items = "[buffer_count],[tc],[buffer_plugin],buffer_number+:+buffer_name+(buffer_modes)+{buffer_nicklist_count}+buffer_filter,[lag],[hotlist],completion,scroll,[kiloseconds]"

My status bar.


/set weechat.color.chat_nick_colors = "cyan,magenta,green,brown,lightblue,default,lightcyan,lightmagenta,lightgreen,31,35,38,40,49,63,70,80,92,99,112,126,130,138,142,148,160,162,167,169,174,176,178,184,186,210,212,215,247"

This will of course only work on 256 color terminals. Also note that I removed ‘blue’ because it’s almost impossible to see dark blue nicks against a black background. ๐Ÿ˜ It does give you a nice pretty rainbow nicklist though.


/set weechat.look.bar_more_down = "โ–ผ"
/set weechat.look.bar_more_left = "โ—€"
/set weechat.look.bar_more_right = "โ–ถ"
/set weechat.look.bar_more_up = "โ–ฒ"

Give me nice arrows instead of the default +++.


Theme

Just some color changes from the default. Not exactly a theme, but…

/set weechat.bar.status.color_bg = 232
/set weechat.bar.aspell_bar.color_bg = 232
/set weechat.color.separator = 234
/set weechat.bar.title.color_bg = 234

Turn the status and spellchecking bar at the bottom of buffers a dark grey so it’s easier to read. Make the separator and title bar a slightly lighter grey.


News

This was kind of stolen and adapted from here. Freenode IRC has a channel named ##news that has a bot that posts links to headlines from all sorts of media. I don’t care about most of it. Some of it is batshit insane conspiracy sites, and some of it is regional stuff for regions I’m nowhere near. So, lets filter it…

/filter add news_interest irc.freenode.##news nick_newsly,nick_newsly_ !^(\s|\[)(Ars Technica|Washington Post|NYT|freenode|EFF Updates|erry's blog|TorrentFreak|BBC - World|SCOTUSblog|Huffington Post|Snopes|Hacker News|LinuxJournal|Politifact).*?\]
/filter add news irc.freenode.##news irc_join,irc_part,irc_quit *

Weather

The following triggers create a /weather command that will create a buffer with the current weather report from http://wttr.in/. You can also type a city name or zip in the buffer itself without the /weather part to get weather info.

/buffer_autoset add exec.exec.weather short_name weather
/trigger add weather command weather
/trigger set weather regex "/\s/_/tg_argv_eol1"
/trigger set weather command "/exec -noflush -norc -noln -buffer weather curl -s http://wttr.in/${tg_argv_eol1}?lang=en"
/trigger add set_title_weather_buffer print "exec.exec.weather"
/trigger set set_title_weather_buffer conditions "${tg_message_nocolor} !~ ^\W && ${tg_message_nocolor} !~ (wttr\.in|@igor_chubin)"
/trigger set set_title_weather_buffer regex "/.*/${tg_message_nocolor}/ /[^:]+:(.*)/${re:1}/tg_message"
/trigger set set_title_weather_buffer command "/buffer set title ${tg_message_nocolor};/buffer set localvar_set_weather ${tg_message}"
/trigger add weather_shortcut modifier input_text_for_buffer
/trigger set weather_shortcut conditions "${buffer[tg_modifier_data].full_name} == exec.exec.weather && ${tg_string_nocolor} !~ ^/"
/trigger set weather_shortcut regex "==(.*)==/weather ${re:1}"

Miscellaneous triggers

Just stuff that doesn’t fit anywhere else. Most of it is stuff I picked up from here and there.

/trigger add close_report signal "buffer_closing" "" "" "/print -core Buffer closed: ${buffer[${tg_signal_data}].full_name}"

This will report the name of buffers that you’ve closed to the weechat main buffer. It’s handy if you accidentally /close something and doesn’t know what it was. Not that I’ve ever done that, mind you.

/trigger add upgrade_scripts signal day_changed "" "" "/script update;/wait 10s /script upgrade" "ok"

Automatically upgrade scripts at midnight.

General notes

Bits and pieces of info I’ve gathered that I found useful, and others might too. Also here so I won’t forget it.

  • The cron.py script docs don’t mention it, but cron.py does support intervals, so you can do something every three hours with */3, etc…

  • Colors are tricky at first because it feels like there’s a relationship between the auto-allocated colors and terminal colors. There isn’t. The terminal colors (what you get when you hit ALT-C in the color buffer) are the colors available to weechat, and their numbers. Use those where you want/need to specify a color.