By default bash completion doesn’t work for linux vserver in gentoo. On the linux vserver pages there’s a bash completion script available for download but it doesn’t compile. I’ve put together a very simple bash completion script here that does only what I need most – expand on available vservers and the safe options.

On gentoo you need to emerge bash-completion first – but you already knew that didn’t you?

Here’s the source for my script /etc/bash_completion.d/vserver

    local cur prev opts
    opts="enter start stop restart chkconf status exec"
	vservers=$(for x in `ls /vservers -1`; do echo ${x} ; done )

	if [[ ${prev} == "vserver" ]] ; then
        COMPREPLY=( $(compgen -W "${vservers}" -- ${cur}) )
        return 0
		COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0

complete -F _vserver vserver

Generated with nanoc - a Ruby content management system for building static web sites.