Category Archives: English

Why I like bzr better than git

Many people I know are using git as VCS and like it a lot. Although I used git in the past and still use it from time for time for some open source stuff, I was never a part of the hype on promoting git and bashing bzr.

Instead, after too much struggling with git, I totally turned to bzr now. Why? Now that’s what this post is about.

Continue reading

Hiding MOTD on bash startup

Usually bash displays /etc/motd at the time of last login on opening a new shell. I do not find that information very useful, as I am opening new shells a lot, so the time does not really mean anything for me. Also, the MOTD rarely changes.

There is a feature in bash to hide these messages by creating a file ~/.hushlogin. This will make bash jump right to the first prompt without any output before.

But just in case the MOTD changes and includes important messages, I enhanced this setup a little bit. Instead of just touching the .hushlogin file, I am storing the old MOTD in it. At startup the old and current MOTD is compared against each other and will be displayed only if it differs. To avoid accidentally missing the MOTD, bash will also ask for my confirmation that I have read it.

Here is the snippet from my ~/.bashrc:

# Show motd only if necessary
cmp -s $HOME/.hushlogin /etc/motd
if [ $? != 0 ]; then
    echo -e "\n==> !!! IMPORTANT: /etc/motd changed !!! <==\n"
    cat /etc/motd
    echo -e "\n==> !!! IMPORTANT: /etc/motd changed !!! <==\n"
    read -e -n 1 -p "Show again? (Y/n) " ans
    if [ "$ans" == "n" ]; then
        cat /etc/motd > $HOME/.hushlogin
    fi
fi

Please note: If you are going to use this, make sure it will not get executed on non-interactive shells. Otherwise it can break tools like scp, sftp or rsync. To ensure this will not be used on non-interactive shells, I am using this conditional at the top of my ~/.bashrc:

if [[ $- != *i* ]] ; then
    # Shell is non-interactive.  Be done now!
    return
fi

Subversion diff commands

Subversion allows to use a custom command for displaying diffs using svn diff --diff-cmd <cmd>. I have been using diff-cmd=colordiff in my ~/.subversion/config for quite some time now. This is really useful, but occasionally I would also like to use vimdiff to get a nice side-by-side diff.

Although this sounds quite easy at first, there are some hurdles. Subversion expects the given command to adhere to the GNU diff parameters, that means it expects it to understand and parse the labels it passes before the actual filenames. This works fine for colordiff, but not vimdiff which only wants the old and new filenames.

For a better diff experience with svn, I set up the following shell function which let’s me choose the program I want to use for diffing.

First, I need a new wrapper script at ~/libexec/svndiff which takes the actual diff program as first option, ignores the GNU diff labels and calls that program passing old and new filename.

#!/bin/bash
BIN=$1
shift 5
$BIN "$@"

Then I define this shell alias in my ~/.bashrc to extend the functionality of the svn command:

function svn() {
    case "$1" in
        diff-plain)
            shift;
            `which svn` diff --diff-cmd diff $@
            ;;
        diff-color)
            shift;
            `which svn` diff --diff-cmd colordiff $@
            ;;
        diff-vim)
            shift;
            `which svn` diff --diff-cmd $HOME/libexec/svndiff -x vimdiff $@
            ;;
        diff-filemerge)
            shift;
            `which svn` diff --diff-cmd $HOME/libexec/svndiff -x opendiff $@
            ;;
        *)
            `which svn` $@
            ;;
    esac
}

Now I can choose the program I find best suited for the current task in a very simplified manner, for example svn diff-vim -c1337.

X-Chat Aqua for Mac OS X

X-Chat Aqua is a very nice IRC client for Mac OS X, but the latest version for download on their website is way out of date and a few years old.

X-Chat Aqua screenshot

X-Chat Aqua screenshot

A while ago libc volunteered to import the old CVS into a new SVN repository and started development on it again. So the version in SVN is now based on xchat 2.8.x, but there are still no binaries available.

Therefore I just put together my own build and I am also offering it as a download for everyone. The application bundle contains an Universal binary for both PowerPC and x86, while I was only able to test them on Leopard.

Additionally, I also replaced the default X-Chat icon with a modern one provided by Ryan Fernandez.

Download X-Chat Aqua: xchataqua-2009-01-21.tar.gz