Baptiste Fontaine’s Blog  (back to the website)

Get RFCs in Your Terminal

When working with Internet protocols, we have to read RFCs a lot. They can be found on the Web, but it’s better to have them directly in the terminal. Ubuntu provide some packages to have them offline, but if you aren’t a sudoer, you can’t install them with apt-get. So I needed a little script to fetch RFCs from IETF’s website and read them locally.

Here comes rfc

rfc was initially a small Bash script (~5 lines) that cURL-ed RFCs and displayed them with less. I used it for the Networking class at Paris Diderot. A few weeks ago, I enhanced it with a local cache (it now download an RFC the first time only), and an offline search feature. Thanks to ecksun, it can also be used to read drafts. The script works pretty much everywhere, and is really simple to use:

$ rfc <number>

For example, get the RFC 6749 (OAuth 2.0) with:

$ rfc 6749

That’s all! Since it’s just plain text, you can pipe it or redirect its output to anything:

$ rfc 42 | lolcat        # rainbow RFC
$ rfc 4534 > rfc4534.txt # local copy

Install

Since that’s a standalone Bash script, you can put it where you want, but the directory must be in your PATH. Here is a basic install:

mkdir -p ~/bin
curl https://raw.github.com/bfontaine/rfc/master/rfc > ~/bin/rfc
chmod u+x ~/bin/rfc

If you don’t have ~/bin in your PATH, add this line in your ~/.bashrc:

export PATH="$HOME/bin:$PATH"

The only requirements are a pager (less is the default, but it’ll use $PAGER if it’s set) and curl (it’ll use $CURL if it’s set, and fallback on wget if curl can’t be found).

For more info, check the project on GitHub.