Bazaar plugins

Information on how to use plugins in Bazaar.

What is a Plugin

A plugin is an external component for Bazaar that is typically made by third parties. A plugin is capable of augmenting Bazaar by adding new functionality. A plugin can also change current Bazaar behavior by replacing current functionality. Plugins often work as a way for developers to test new features for Bazaar prior to inclusion in the official codebase. Plugins can do a variety of things, including overriding commands, adding new commands, providing additional network transports, or customizing log output. The sky is the limit for the customization that can be done through plugins.

Where to find Plugins

We keep our list of plugins on the page.

How to Install a plugin

Installing a plugin is very easy! One can either install a plugin system-wide or on a per user basis. Both methods involve creating a plugins directory. Within this directory one can place plugins in subdirectories. For example, plugins/bzrtools/.

Two locations are currently checked: the bzrlib/plugins directory (typically found in /usr/lib/python2.4/site-packages/bzrlib/plugins/) and $HOME/.bazaar/plugins/.

One can additionally override the home plugins by setting the environment variable BZR_PLUGIN_PATH to a directory that contains plugins. The installation of a plugin can be checked by running bzr plugins at any time. New commands can be seen by running bzr help commands. The commands provided by a plugin are shown followed by the name of the plugin in brackets.

Plugins work particularly well with Bazaar branches. For example, to install the bzrtools plugins for your main user account, one can perform the following:

bzr branch

When installing plugins the directories that you install them in must be valid python identifiers. This means that they can only contain certain characters, notably they cannot contain hyphens (-). Rather than installing bzr-gtk to ~/.bazaar/plugins/bzr-gtk, install it to ~/.bazaar/plugins/gtk.

Writing a plugin

Plugins are very similar to bzr core functionality. They can import anything in bzrlib. A plugin may simply override standard functionality, but most plugins supply new commands.

To create a command, make a new object that derives from bzrlib.commands.Command, and name it cmd_foo, where foo is the name of your command. If you create a command whose name contains an underscore, it will appear in the UI with the underscore turned into a hyphen. For example, cmd_baz_import will appear as baz-import. For examples of how to write commands, please see

Once you've created a command you must register the command with bzrlib.commands.register_command(cmd_foo). You must register the command when your file is imported, otherwise bzr will not see it.

Bzr will scan bzrlib/plugins and ~/.bazaar/plugins for plugins by default. You can override this with BZR_PLUGIN_PATH. Plugins may be either modules or packages. If your plugin is a single file, you can structure it as a module. If it has multiple files, or if you want to distribute it as a bzr branch, you should structure it as a package, i.e. a directory with an file.

Please feel free to contribute your plugin to BzrTools, if you think it would be useful to other people.