I don’t really like computers. I need my tools to be obvious, and computers are as far from obvious as you can find. I need things to be organized, and computers seem to follow the second law of thermodynamics religiously. But I still try.

My latest attempt is called OpenBSD. I’ve begun to use it because it is just a little bit more obvious and organized than GNU/Linux. On this page, I thought I’d explain my personal setup and collect all the “tips and tricks” that I’ve come across.

Installation

For the search engines, here are a couple of keywords: how to easily install OpenBSD on an existing partition.

OpenBSD lacks a graphical installer. Luckily, the text-based installer is one of the best I’ve used. However – as always, when it comes to disk partitioning, you need to be sure about what you’re doing, and I just couldn’t figure out how to use the version of fdisk provided by OpenBSD. Here’s what I did instead:

  1. Booted back into Debian
  2. Used Debian’s fdisk to create an OpenBSD partition (A6)
  3. Resumed the installation process

Now, the installer will ask you whether you want to install the system onto the already existing OpenBSD partition – no further partitioning needed!

Man pages

If you’ve read about OpenBSD before, you’ve probably been advised to read the man pages. I’ll echo this advice, because the man pages are usually very good.

If you don’t enjoy reading man pages through less, you can easily convert them to PDF or HTML (insert your favorite PDF reader or WWW browser):

MANPAGER=mupdf man -T pdf intro
MANPAGER=seamonkey man -T html intro

The PDF pages are much easier to read thanks to the typography, while the HTML pages are much easier to browse thanks to the hyperlinks.

X11

One of the things I like about OpenBSD is that it asks me on installation whether X should be automatically started. I answered no! I don’t spend much time in the console, but as I said, I want organization; every program that is automatically started is a tiny drop of confusion, and drops are what makes up oceans. You could say that I use logos to separate order from chaos – I mean, I use startx.

… speaking of which, let’s go through my ~/.xinitrc:

xset m 1/1 1                # no mouse acceleration
xinput set-prop 7 239 0.9   # mouse sensitivity

The xset interface is straight-forward; this also applies to its man page. To know what parameters to put into xinput, use its options list and list-props <device>. The numbers above apply to my mouse.

export LC_CTYPE=en_US.UTF-8
setxkbmap usx

As per locale(1), OpenBSD currently supports only two character encodings: C (ASCII) and en_US.UTF-8.

The usx keyboard map is my own variant of the us map.

if [ -x /usr/local/bin/dbus-launch -a -z "${DBUS_SESSION_BUS_ADDRESS}" ]; then
    eval $(dbus-launch --sh-syntax --exit-with-x11)
fi

I need dbus for the trash can in my file browser to work.

wmaker

Finally, my window manager is started.

Shell

OpenBSD comes with a version of the Korn shell called the public-domain Korn shell, or (PD)ksh for short. It has the following qualities:

  • Lightweight
  • Conventional
  • Mostly POSIX-compliant
  • Supports custom completion

Configuration

There are two files relevant to your ksh configuration: .profile and .kshrc, both residing in your home directory.

.profile is run when you log in – it is a good place to start things like ssh-agent. To have ksh execute .kshrc for interactive shells, .profile must include the following line:

export ENV="$HOME/.kshrc"

Personally, I keep most configuration in .kshrc. Here is a selection:

HISTFILE="$HOME/.ksh_history"
HISTSIZE=5000

This activates command history, which is otherwise disabled by default.

alias __A=`echo "\020"` # up arrow = ^p = back a command
alias __B=`echo "\016"` # down arrow = ^n = down a command
alias __C=`echo "\006"` # right arrow = ^f = forward a character
alias __D=`echo "\002"` # left arrow = ^b = back a character
alias __H=`echo "\001"` # home = ^a = start of line
alias __Y=`echo "\005"` # end = ^e = end of line

These aliases, courtesy of Tim, make it a bit easier to browse history.

set -o emacs

I personally prefer Emacs key bindings, but I should mention that ksh supports also vi-like bindings.

alias ls='colorls -G'

colorls is like ls, except it supports colors. It can be installed via pkg_add colorls--.

bind -m '^L'='clear^J'
bind -m '^[l'='ls^J'

These are two key bindings that I find useful: Ctrl-L to clear the screen and Alt-L to run ls.

set -A complete_git -- status commit push log

Finally, an example of custom completion, a feature that is unique to this ksh implementation.

Note that I personally use mksh, another implementation of the Korn shell developed by the creator of MirBSD.