Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 4 down vote accepted

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

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

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
add comment

Your Answer

 
discard

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.