June 27, 2007

Blogging from the command line

Author: Scott Nesbitt

While podcasting and video blogging are all the rage, many people still prefer the simplicity of the typed word for expressing themselves online -- that is, a blog. However, popular blogging platforms like WordPress and Movable Type can be tough to configure and maintain. On the other hand, you might not want to use an online service like Blogger or TypePad because you want complete control over your blog. If you're not afraid of the command line, take a peek at Bash Blogger. As its name implies, this application is a bash script that automates all of your blogging tasks (aside from writing, of course).

Bash Blogger's shell scripts come in a 36KB archive. After you download it, extract the archive somewhere in your path, then run the script bblog_setup, which will create a directory containing Bash Blogger's configuration file and a bunch of supporting files. If all goes well, the installation should take only a few seconds.

I installed Bash Blogger on computers running Ubuntu 6.06 LTS, DeLi Linux 0.7.1, and Windows XP with Cygwin. For some reason, Bash Blogger wouldn't install properly on Ubuntu. After a bit of head-scratching and a little cursing, I discovered the file CONFIG_DIR.tar.gz in the folder containing the Bash Blogger files. It turns out that the setup script is supposed to extract the contents of this archive to create the directory containing the application's configuration information. I simply extracted the archive manually and everything started working.

Getting started


Once the application is installed, run bblog to get going. You'll see a menu that contains options for writing new blog entries (called articles), inserting or removing pages, adding links and welcome message, or changing the look and feel of your blog.

Bash Blogger uses vim for editing text. To start creating a blog entry, you just start typing. If you want to add formatting, such as bold or italics, blockquotes, tables, or links, then you need to add the HTML tags by hand. Bash Blogger will only wrap text in paragraph tags (<p> and </p>).

If you don't like adding HTML code by hand, you can take advantage of Bash Blogger's support for Markdown, a text-to-HTML conversion utility that uses a simple formatting syntax.

Some of Bash Blogger's other features include an automatically generated RSS feed, the ability to output standalone pages that aren't part of your blog, and a navigation breadcrumb trail. All of your blog entries are stored in a simple flat file database, which has less chance of becoming corrupt and, consequently, less chance of losing your data than a database like MySQL.

The file .bblog.conf determines how Bash Blogger behaves and controls certain aspects of your blog. You can change the name and location of your blog, the editor that you want to use (in case you're not a fan of vim), the character set your computer uses, and whether you want an RSS feed on the front page.

You can edit the configuration file in a text editor or from within Bash Blogger. I suggest making a backup of the file before making any configuration changes; I botched an edit and Bash Blogger stopped working properly. I had to copy the default configuration file from the Bash Blogger archive to my configuration directory to get the app to work again.

Publishing your blog

So, you've installed and configured Bash Blogger, and you've written a new blog entry. You have several options for publishing it.

First off, you can just have Bash Blogger on your filesystem or home network and use it as a personal journal or bulletin board.

If you want to make your blog available to the Web, and your Web host offers shell access, you can install Bash Blogger on your Web site. From there, you can log in using SSH and run the script. This enables you to securely edit and post blog entries no matter where you are, as long as you have access to an SSH client.

If you prefer to work on your blog from the privacy of your home, you can upload your blog entries to your Web site using SFTP, scp, or rsync. You can do this automatically by selecting an option from Bash Blogger's menu. To get all of this to work, you'll need to edit the file .bblog.conf to point to your Web site and the directory that contains your blog. You'll also need the scp or rsync utilities and SSH installed on both your computer and your Web server.

Like most blogging tools, Bash Blogger enables you to apply themes that change the appearance of your blog. There are only five themes available, but if you're a dab hand with XHTML and CSS you can whip up your own.

To use a theme, just download the archive containing the theme files and extract it to the folder .bashblogger/templates (which was created when you installed the app). You can then select the theme from the Bash Blogger settings menu. The only drawback is that you can't preview the changes at the command line; you must republish the blog for the changes to take effect, then open it in a Web browser to ensure that everything worked.

Overall impressions

Bash Blogger will appeal to someone who is comfortable with working at the command line, and who needs a simple, lightweight tool for posting blog entries. The software is easy to use and quick -- even on the 333MHz Pentium III with 256MB of RAM that I installed it on. It contains just enough features to publish a simple and attractive blog. I found Bash Blogger to be an effective way to create and maintain a blog. Even though I have a blog published with WordPress, I'm seriously considering creating a new one with Bash Blogger.

Scott Nesbitt is a Toronto-based technical writer and journalist who is a big fan of useful command-line utilities.


  • Internet & WWW
Click Here!