Tuesday, October 19, 2010

Bikeshed: bzrp (bzr with a sensible-pager)

I'll admit it ... I'm a huge fan of bzr. I'm conversational in git, but I really love the ease of use of bzr. It's friendly, convenient, and well documented.

I really only have one complaint... I really wish it paged output to sensible-pager, when running in an interactive terminal and the output is more than one screen-full.

I talked to Robert Collins about this in Wellington at LCA2010 earlier this year. He was lukewarm to the idea, asking me why don't I just pipe the output to sensible-pager. Heh. Sure, I can do that.

Okay, okay, so I created a simple alias, and eventually this wrapper script, bzrp, which basically has that effect.

Try it for yourself!
bzrp log --include-merges
bzrp diff
bzrp cdiff
This works with any bzr command that has output on standard out.

For what it's worth, I'm pronouncing this "ba-zerp" for now :-)

If you find this useful, install the bikeshed package from Natty, or from the Bikeshed PPA for other versions of Ubuntu.

:-Dustin

10 comments:

  1. You can also do this:

    mkdir -p ~/.bazaar/plugins
    bzr branch lp:bzr-pager ~/.bazaar/plugins/bzr-pager

    And all bzr commands will be paged.

    ReplyDelete
  2. Hi Dustin,
    there is also a plugin for bzr which directs output of various commands to $PAGER, I'm using it since ages, and I'm very happy with it ;)
    bzr get http://bzr.oxygene.sk/bzr-plugins/pager/

    ReplyDelete
  3. I've been using https://launchpad.net/bzr-pager

    ReplyDelete
  4. Dustin: fyi there was a bzr-pager plugin previously that auto-pipes all commands to sensible-pager. Though I quite like your version, using a different prefix cmd :)

    https://launchpad.net/bzr-pager

    ReplyDelete
  5. Is this different to the bzr-pager plugin? One of my new-install tasks is to run “bzr branch lp:bzr-pager pager” in ~/.bazaar/plugins.

    ReplyDelete
  6. Ah, interesting. Thanks everyone for the pointer to bzr-pager.

    I did apt-cache search for something like this, but turned up no hits.

    Doesn't look like bzr-pager is packaged yet?

    :-Dustin

    ReplyDelete
  7. Please add grievances to bug #213718 (or one of its dups)! It's one of those things that really should have been fixed for everyone by now.

    ReplyDelete
  8. sladen,

    Ah, yes, thanks:
    https://bugs.edge.launchpad.net/bzr/+bug/213718/comments/11

    :-Dustin

    ReplyDelete
  9. I looks like bzrp doesn't handle arguments with spaces in them. You may need to quote "$@".

    I'be been using a script for bzr diff and bzr log to add pagination/colourizing, e.g. my ~/bin/bzrdiff is (going to be horrendously mangled on this blog, I bet)


    #!/bin/bash
    # bzr diff with nice colours
    args="--diff-options=-p $@"
    if test -t 1 && test -x /usr/bin/colordiff; then
    # stdout is a tty
    exec bzr diff $args|colordiff|less -R
    else
    exec bzr diff $args
    fi

    ReplyDelete
  10. Thanks Marius. I just committed a fix.

    ReplyDelete

Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.
* bugs.launchpad.net
* stackexchange.com

Thanks,
:-Dustin