Useful rxvt-unicode (URxvt) Plugins
I’ve been using rxvt-unicode (
urxvt) for years. But, I never really bothered to customize it beyond adding in some simple font changing hotkeys. I discovered that
urxvt can be customized with Perl plugins. This post shows some of the plugins I’ve started using.
For this post, I will use the terms terminal and
urxvt interchangeably. The plugins are configured in your
~/.Xdefaults file, and to have this file take effect, run
xrdb -merge ~/.Xdefaults
. The hotkeys are defined with key names from keysymdef.h as part of X11.
Homepage (part of
This is by far the most useful plugin. If you ever need surgical precision to select a particular chunk of text in your terminal, you can use this plugin. It gives you Vim-like normal mode navigation in your terminal — and then you can use hotkeys like
V to select chunks of text, and use
y to copy it to your X primary buffer.
I use the snippet below in my
! keyboard-select URxvt.keysym.M-s: perl:keyboard-select:activate URxvt.keysym.M-r: perl:keyboard-select:search
Alt-s for you folks not familiar with Emacs-style shortcut-naming) in the terminal gives you Vim-like normal mode like I mentioned above. The other shortcut,
M-r, gives your reverse search against your terminal’s buffer.
M-r sink in. This means that your terminal is basically running a virtual
less pager. Any time you want to go search against some text in your terminal, just use
M-r and search; use
N just like
M-r is basically doing
M-s followed by
?. So, if you like searching forwards (not backwards), just do
M-s and then
/. But considering how terminal buffers are always above the cursor, it makes sense to search backwards by default with
M-r. For me this runs against my habit of using
/, but there you have it.
Homepage (part of
! clipboard ! update clipboard whenever primary gets updated URxvt.clipboard.autocopy: true URxvt.keysym.M-c: perl:clipboard:copy URxvt.keysym.M-v: perl:clipboard:paste URxvt.keysym.M-C-v: perl:clipboard:paste_escaped
. To be honest I think the
autocopy feature is a bit flaky (at least when using these shortcuts inside a NixOS VirtualBox VM from a Mac) — but that’s not that important.
M-c copies the X11 primary buffer (aka X selection) to the clipboard buffer.
What’s really nice is the
M-v shortcut — it pastes the clipboard buffer, not the X11 primary buffer (there is
S-<insert> (Shift-Insert) for that). Now you don’t have to type
$(xsel -b) for the same thing.
Alt-Control-v) does the same thing, but escapes any special characters. This is very handy — a simple use case might be using
M-s (search shortcut discussed above) to find a particular file with a long name (think MP3 files) from the output of
ls — you can then just use
v to copy that filename to the X11 buffer, then use
M-c to copy it to clipboard buffer (if
autocopy is working this step is unnecessary), then use
M-C-v to paste it in, escaping things like space characters so that you can use other tools like
mv on them more easily.
Homepage (part of
! url-select. We can middle-click on any url and this will launch the browser ! defined by `URxvt.url-select.launcher`. URxvt.keysym.M-u: perl:url-select:select_next URxvt.url-select.underline: true URxvt.url-select.launcher: firefox
. Now you can use
M-u to jump between any URL that was printed to the terminal buffer. Use
k to jump to the next/previous URL, and
y to copy it to your X primary buffer (and
M-c to make sure it’s also in the clipboard) for easy URL handling. Or, simply press
ENTER to open that link in your browser. Next time you grab your mouse to carefully highlight a URL in the terminal, think again!
This plugin allows you to scale fonts up or down.
! `font-size` plugin URxvt.keysym.C-minus: perl:font-size:decrease URxvt.keysym.C-equal: perl:font-size:increase ! The default font increase step size is 1. This is for portability across all ! fonts (some fonts do not support particular font sizes). Because changing font ! size only really makes sense for anti-aliased fonts (Terminus is bitmapped), ! and because anti-aliased fonts support any size, it makes sense to just use a ! size step of 4 for faster transitions between font size changes. URxvt.font-size.step: 4
. This is pretty self-explanatory. Use
C-equal to change your font size as needed — perfect for screencasts or demos!
Now that I use these plugins, there’s even less interruption to use the mouse. I hope you find them as useful as I have.