Russel Winder's Website

A Bash Completion Script for Rant

The Problem

Rant is a build tool that uses Ruby as the underlying scripting language. It is a competitor to SCons (which uses Python as the programming language) but perhaps more especially to Rake, which like Rant is build on Ruby. There has been a lot written about the relationship of Rake and Rant elsewhere and I am not yet in a position to comment on this as I am only just beginning to try Rant having done some work with SCons and Rake.

The problem is that whilst Rake comes with a Bash completion script, Rant does not.

The Solution

The solution is totally clear: create a Bash completion script for Rant. Given the similarity between Rake and Rant, and having done equivalents for SCons and Gant, it is easy to take the Rake script and edit it a bit. So I came up with a script (that you can download by clicking here) that seems to do the job. It almost certainly has errors and/or bugs but for the moment it "works for me".

To use this script you can do one of:

  • Ensure you have a ~/.bash_completion file that includes all the scripts in a personal Bash completion script library. I have a directory ~/bash_completion.d in which I put the various scripts – copying directly the way that Bash organizes scripts in /etc. My ~/.bash_completion file then contains a copy of the relevant bit of the system script:
# -*- mode:shell-script -*-

for file in bash_completion.d/*
    [[ ${file##*/} != @(*~|*.bak|*.swp|\#*\#|*.dpkg*|.rpm*) ]] &&
    [ \( -f $file -o -h $file \) -a -r $file ] &&
    . $file
  • Append the contents of the file to your ~/.bash_completion file.
  • Put the file in /etc/bash_completion.d with all the other system-wide scripts.

The last has the advantage of working for all users of the machine but does require super-user privileges. I use the first as being the easiest.

Do email me if you have any feedback.

Copyright © 2017 Russel Winder -