3

Everytime I run git branch -a, an editor (I suppose nano) is opened to show the output, but I wish the output is by using the same console (like cat). How do I get it?

My info:

  • OS: Manjaro Linux x86_64
  • Kernel: 5.12.9-1-MANJARO
  • Shell: zsh 5.8
  • Git: 2.32.0
wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • 2
    Do you have `nano` configured as the pager for Git to use? I can't imagine why else Git wouldn't just write to standard output. – chepner Jun 23 '21 at 16:30

2 Answers2

4

It seems it's the "pager" of Git that shows up here (if you have many branches).

You can try if one of these works for you (see the doc of git config):

  • git --no-pager branch -a
  • GIT_PAGER=cat git branch -a
  • git config --global pager.branch false or more aggressively git config --global core.pager cat; then git branch -a

FTR, the "pager" that is triggered in practice is normally less (not nano): see this other section of git config's doc.

ErikMD
  • 13,377
  • 3
  • 35
  • 71
  • The OP might also consider setting the F and X options when using `less`. The F option makes `less` exit immediately if the entire output fits in one "page", and the `X` option inhibits any alternate-screen-mode that is otherwise annoyingly impossible to turn off in macOS Terminal, for instance. – torek Jun 23 '21 at 22:35
3

if you just try to pipe | to another program, does it behave the way you expect?

git branch -a | cat

(perhaps a non-useless use of cat?)

ti7
  • 16,375
  • 6
  • 40
  • 68