How to install bronze powerline-like prompt on Ubuntu

Bronze is an application (written in Go) that let’s you add a powerline-like prompt to your terminal, the author states that theoretically it should be compatible with any shell, but the three supported shells are bash, zsh and fish.

I’ve used a couple of similar applications: powerline-shell and powerline-go, both of which work really well (and have more modules than bronze), but bronze looks a bit nicer because of the icons it uses by default (provided by a “patched” font, that is).

The author provides an already compiled binary for Linux 64 bits (https://github.com/reujab/bronze/releases), but it does not run in any current Ubuntu version because it requires a more recent version of the libgit2 library than the ones provided by Ubuntu. So, in order to use bronze in Ubuntu, you’ll need to compile libgit2 yourself.

Install bronze from binary

Download bronze binary from https://github.com/reujab/bronze/releases, latest version is v1.1.1.
Add binary to the PATH environment variable, you can do it by adding the directory where you placed the bronze binary to the $PATH variable, or just copy/move the binary to a directory that is alredy in the $PATH, e. g. /usr/local/bin, let’s do the latter:

sudo cp bronze /usr/local/bin/

If you try to run bronze now, you’ll get an error:

$ bronze
bronze: error while loading shared libraries: libgit2.so.26: cannot open shared object file: No such file or directory

This is because bronze can not find the libgit2 library. Ubuntu does not install it by default, and what’s more, it only offers the older version 24. We need to download the source of libgit2 and compile it ourselves.

Set up compiler stuff

You’ll also need some tools to be able to compile the source code, get them by installing the build-essential package:

$ sudo apt install build-essential

Now let’s compile libgit2.

Compile and install required libgit2 version

Download libgit2 version 0.26 from https://github.com/libgit2/libgit2/releases/tag/v0.26.0
Uncompress it:

tar -xvzf libgit2-0.26.0.tar.gz

Move to the uncompressed directory and compile the library:

$ cd libgit2-0.26.0/
$ mkdir build && cd build
$ cmake ..
$ cmake --build .
$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr
$ sudo cmake --build . --target install

After installing the library, you should be able to run bronze without errors:

$ bronze
NAME:
   bronze - a cross-shell customizable powerline-like prompt with icons

USAGE:
   bronze [global options] command [command options] [arguments...]

VERSION:
   0.0.0

COMMANDS:
     init     Initializes the shell for use of bronze
     print    Prints the prompt with the specified syntax
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

Configure bronze

Now we need to configure bronze, you do it by editing your .bashrc (or .zhrc) file and adding these lines to the end:

# bronze configuration
BRONZE=(status:black:white dir:blue:black git:green:black)
export BRONZE_SHELL=bash

eval "$(bronze init)"

For the changes to have effect, you need to open a new terminal window, but at this moment you’ll get something like this:

The problem is that the font in use does not provide the icons required by bronze, you can install a font from the Nerd Fonts repository, just choose the one you prefer from here: https://github.com/ryanoasis/nerd-fonts/releases
For example, let’s download the DejaVuSansMono.zip file and install the font files included in it:

$ mkdir ~/.local/share/fonts
$ cd ~/.local/share/fonts
$ wget https://github.com/ryanoasis/nerd-fonts/releases/download/v1.2.0/DejaVuSansMono.zip
$ unzip DejaVuSansMono.zip

And now you should select one of the new installed fonts for your terminal, once you do you should see something like this in your prompt:

Install bronze from source

If you’d like to take advantage of the more recent bronze features without waiting for them to be released, or if you are still using a 32 bit Ubuntu version, you’ll have to install bronze by compiling the bronze source code yourself, bronze documentation indicates the required steps:

  1. Install and setup Go.
    You can use the go version included in Ubuntu’s repositories, just make sure to set the $GOPATH variable if you are running a go version lower than 1.8 (e. g. Ubuntu Xenial 16.04).
  2. Install libgit2 development packages.
    Just compile libgit2 following the steps above, the Go bindings are installed by the next step.
  3. run go get github.com/reujab/bronze.

I’ve succesfully installed bronze in two of my machines, one running Xubuntu 16.04 (Xenial) 64 bits (installed from binary), and the other with Xubuntu 17.10 (Artful) 32 bits (installed from source), and I’m quite happy with the performance of the tool.

Next Ubuntu version, 18.04 (Bionic) will include version 26 of libgit2 library (https://packages.ubuntu.com/bionic/libgit2-26), so no compiling step should be required to run bronze there (if installing the bronze binary).

Be the first to comment

Leave a Reply