Bash completion for msynctool

Bash completion is that you can hit the tab key on the console and you will see some proposals or better next parameter is displayed automatically. Please note that the Bash completion means this page describes auto completion for Bash only.

Limitations

It is not possible to display always perfect options. This happens because not all parameters are hundred percent unique in the mathematical way of thinking. Such parameters are documented here:

--conflict::

The option expects a memberid of the group which is synchronized. The problem is that the order of the parameters is not defined and so it is determinable which group will be synchronized. Therefore all groups are scanned for their memberids and all these memberids are displayed. Additionally the characters d (duplicate), i (ignore) and n (keep newer) are displayed.

--slowsync::

The option expects an objtype of the group which is synchronized. Like mentioned before the group is not determinable and so all available objtypes of all groups are displayed.

--disable-readonly --enable-readonly::

These two options have an optional third parameter. Therefore it is necessary to display all available parameters (--something) and the available objtypes for the choosen group at once. This is not really comfortable but it is just like that. Additionally the member of the group is not scanned explicitly. Only the group is scanned and all objtypes of the group are displayed.

Installation

There are three ways of installation:

  • Install a release and hope that bash completion is included
  • Install only the necessary shell script
  • Install from SVN checkout

Install a release

If you install a release which already includes the necessary msynctool.sh script then you can proceed with configuration.

Install shell script only

Download http://svn.opensync.org/multisync/trunk/tools/msynctool.sh and install it in /etc/bash_competion.d/. After this continue with configuration.

Install from SVN checkout

Checkout msynctool from SVN

svn co http://svn.opensync.org/multisync/trunk msynctool
cd msynctool

You can now copy the file tools/msynctool.sh like described above into the correct position or you install it by installing msynctool. Please note that the default installation prefix cmake is /usr/local. So the script is installed at '/usr/local/etc/bash_completion.d/'. If this happens then you must copy it manually to the correct position at /etc/bash_completion.d/ because the default script '/etc/bash_completion' only supports one directory with scripts for completion.

mkdir /tmp/msynctool
cmake . -B/tmp/msynctool
cd /tmp/msynctool
make
sudo make install
cp /usr/local/etc/bash_completion.d/msynctool.sh /etc/bash_completion.d/

Configuration

The only thing which you have to do is to activate the Bash completion for your account. You have to add the following line to your .bashrc or to the global /etc/bash.bashrc.

if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

The most modern distributions already include a similar line in their global bash.bashrc. Sometimes you must uncomment it but this is quite simple. After the next login the Bash completion for msynctool should work.

BTW if you want to test your local installation then you have only to run the following to update the Bash completion in your actually running shell:

. /etc/bash_completion

Disclaimer

This description was created and tested with a Debian Sid. It can happen that some paths or files are named different on other Linux distributions or operating systems.