Saturday, October 16, 2010

vim custom syntax

I've been known to write blog posts. I tend to draft them in a text file, just because it's easier to edit in vim than in a text box and I get an automatic backup. The format is sorta HTML, but not quite: I don't have to bother with <p> tags, etc. To avoid confusion, I give them a file extension of .blog, but I want vim to highlight them like .html files.

Getting vim to do this is actually pretty straightforward, but figuring out how was a pain. The info is scattered across a bunch of help files and cluttered with references to old versions and non-recommended options. So I'm pulling it together here.

First, create a ~/.vim/syntax/blog.vim file containing:
runtime! syntax/xhtml.vim

This says to invoke the xhtml syntax file. (You could do plain html instead.)

Then you need to tell vim to use the blog.vim syntax when you're editing a .blog file. To do this, create a ~/.vim/ftdetect/blog.vim file containing:
au BufRead,BufNewFile *.blog        set filetype=blog

That's it.

Tuesday, July 6, 2010

gnupg-agent installation

I ran into a little Ubuntu package installation quirk the other day. I wanted to install gpg-agent on a remote server. It's a headless server, so it doesn't have any window manager crap installed. gpg-agent has to be able to prompt you for keystore passphrases, and normally, it would pop up a window for that. So when I first tried to install gpg-agent, it said it would also have to install this alarming list of xwindows and GTK packages. Didn't want that.

What's actually going on is that gpg-agent just has a "pinentry" dependency. The default pinentry is is pinentry-gtk2, which of course depends on gtk and xwindows and all that. But there's also an curses (text mode) pinentry package that satisfies the dependency. That's what you'd want if you're ssh-ing into the machine. If that's already installed, gpg-agent won't ask for anything more.

So the commands are:
sudo apt-get install pinentry-curses
sudo apt-get install gnupg-agent

Saturday, July 3, 2010

About

Hi! My name's Colin. I'm a programmer. Often, in the course of my work, I spend Way Too Much Time beating my head against the computer, trying to figure out why some bit of software doesn't work the way it should (or how it's supposed to work in the first place). Sometimes, I'm saved that frustration by some clever person somewhere out there on the web who's already figured it out and written about it. This blog is my way of returning the favor, in a fuzzy, karmic sense. It's basically a dumping ground for random technical minutiae. It's a reference, rather than something you'd actually want to subscribe to.