CurtisFree.com Blog

I'm a geek, and I have .

My preferred monospace fonts

As a programmer and command-line enthusiast, I spend a lot of time looking at monospace fonts. For many years, I enjoyed using what has been for years a popular default: Bitstream Vera Sans Mono.

A few months ago, I spent a great deal of time trying out different monospace fonts. Here, I’ll present a brief list of my favorites; the font specification strings and screenshots represent my preferred configuration for each of the fonts in my preferred terminal, rxvt-unicode:

  1. Tamsyn
    -*-tamsyn-medium-r-*-*-14-*-*-*-*-*-*-*

    There's just something about Tamsyn that I like (in addition to its website, of which I'm a big fan).

    Unfortunately, though it's a sans-serif font, the glyph shapes do seem to possess some “serif” qualities and seem jagged (pixelated). I'm also not a fan of the “sharp” m and w glyphs at smaller sizes (as shown). I refer to the m as a “Gmail m.”

    I do use Tamsyn on my virtual consoles, as my favorite (see below) is a derivative of Tamsyn but is not yet available in a console-capable format.

  2. DejaVu Sans Mono
    xft:DejaVu Sans Mono:size=9

    DejaVu Sans Mono is little more than Bitstream Vera Sans Mono – so here, I'm not straying far from my “safe default”; but I prefer DejaVu because it supports a larger character set (even though, admittedly, I don't make use of it).

    This is the only non-bitmap font on the list.

    Among other things, this means that much of its appearance is dependent on system font settings. Bitmap fonts, on the other hand, are much more uniform in appearance across systems (though they, too, are subject to some variation). Working with multiple Linux distributions and OS X, DejaVu Sans Mono can look crisp or blurry – or perhaps the character spacing might not be consistent across applications. While this is no fault of the font itself, it's worth noting.

    I continue to use DejaVu in some terminals/on some machines; and it's my preferred font for displayed code (e.g., in code blocks on this page).

  3. Terminus
    -*-terminus-medium-r-*-*-12-*-*-*-*-*-*-*

    Terminus is well-known in the Arch Linux community – and for good reason. It's simply a great font. Terminus glyphs are perhaps the simplest and most readable I've seen.

    You might notice that the directory names in the screenshot are not displayed in bold face: this size of the Terminus font has no bold face. I don't consider that a problem (in fact, I like the clean look of a terminal with no bold fonts); but others might.

    Terminus is “tied” with DejaVu as my favorite for use on some systems.

  4. Termsyn
    -*-termsyn-medium-r-*-*-14-*-*-*-*-*-*-*

    Termsyn is a middle-ground between Terminus and Tamsyn.

    Termsyn is probably the least popular on the list, but it's my default font in rxvt-unicode on my personal Arch machine. Using my preferred size for each font (pictured here), Termsyn is a little larger than Terminus. Furthermore, the “serif” qualities that I dislike in Tamsyn are not prevalent in Termsyn, due to its inheriting simple glyph shapes from Terminus.

Quickly copy last Git commit hash

A typical portion of my Git workflow involves the following:

  1. Local git commit
  2. git push to upstream remote
  3. Add a comment to an issue tracker that includes the new commit hash

A simple shell (ZSH, BASH, or similar) function makes the last step a little bit easier:

gitcp() { git log -1 --format="%H" | xclip -in; }

After running gitcp, the hash of the last commit is in X’s primary selection and can easily be pasted into a comment box in the issue tracker.

Depending on your preferences, you can instruct xclip to copy into a different X “selection” – or you can even use Autocutsel to sync your X selections.

Not using X11? There are xclip alternatives for OS X and Windows, so you can spin up your own helper utility.

Adding the total line count to Vim's status line

By default, Vim displays some information about the current buffer/state on its command line (the last line in the window):

As of late, I like asking Vim to display a second line of information at all times (:set laststatus=2). This leaves some information displayed on the command line but moves other info to the “status line”:

As you can see in both screenshots, I have enabled Vim’s “ruler” (:set ruler), which gives line, column, and position (the last few fields in the commandline and the status line, respectively). While this information can certainly be helpful, one might also wish to know a little more detail about his/her progress through the buffer.

With 'ruler' set, Vim tries to do this; but sometimes, it can be useful to have the total line count to compare with the current line number – not just a relative position. Fortunately, Vim allows users to customize the contents of its status line.

The 'statusline' option dictates what information is displayed on the status line. Since that option is blank by default, one must dig through the documentation to find the true default. Here’s the relevant snippet:

Emulate standard status line with 'ruler' set
  :set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P

%l is the current line number. I like to place the total line count (%L) just after that, as a fraction:

:set statusline=%<%f\ %h%m%r%=%-14.(%l/%L,%c%V%)\ %P

If you expect to edit very large buffers, you might also wish to give Vim some additional space to the right for many-digit line counts. Here, we give the line/column count group 20 characters instead of the default 14:

:set statusline=%<%f\ %h%m%r%=%-20.(%l/%L,%c%V%)\ %P

This gives a status line like the following:

Of course, you can add %L anywhere you like in your own status line. To make this setting “stick,” add that line (minus the leading :) to your ~/.vimrc.