Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am frequently working with subversion in console using its client svn. One of common tasks is viewing svn log; however its output is usually pretty massive despite of --limit option. I would like to pipe the output to my $PAGER (which is less to be exact), just like git log does. I wonder if this can be achieved with zsh advanced completion features; i.e. whenever I type

svn log path1 path2 path3<Enter>

the piping construction will be appended:

svn log path1 path2 path3 | $PAGER

This resembles to me the way aliases work, but from the "other side".

Is this possible in zsh?

share|improve this question
up vote 5 down vote accepted

You can do this with a shell function. Just put this in your ~/.zshrc.

svn() {
    if [ "$1" = "log" ]
        command svn "$@" | less -FX
        command svn "$@"

I've tested that with bash and p4, but it should work the same with zsh and svn. The -FX options to less tell it to quit if the entire file fits on the first screen and not to switch to the alternate screen. This makes it appear that less wasn't used at all if the output fits on one screen.

share|improve this answer
I like the solution. – ulidtko Feb 4 '11 at 21:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.