1

I have an xargs function that calls git commands recursively.

When I now call gitr log I have to hit enter until the end or q to get the next xargs call to run.

Can I tell xargs to skip user input or output everything of less at once?

1
  • 2
    You can call git with the --no-pager option if you want it to dump out everything without running less. Commented Mar 15, 2015 at 17:11

3 Answers 3

1

You can call git with the --no-pager option if you want it to dump out everything without running less. Here are details from the man page:

--no-pager

Do not pipe git output into a pager.

0

try redirecting stdin or stdout or both.

eg:

gitr log < /dev/null | cat
0

It isn't xargs that's prompting you, it's less. And less isn't invoked by xargs, but by git.

Each invocation of git operates on one repository at a time, so if you want to operate on multiple repositories, you'll need to tell git not to invoke a pager. You may want to invoke a pager manually though.

Here's some untested proof-of-concept code that causes git not to invoke a pager, but invokes a pager on the output from all the git invocations when called interactively. Your code goes into the run_git auxiliary function.

gitr () {
  if [ -t 1 ]; then
    run_git \
      -ccolor.branch=always "$@" -ccolor.grep=always -ccolor.showbranch=always -ccolor.status=always \
      | ${GIT_PAGER:-less -r}
  else
    run_git "$@"
  fi
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .