Reputation: 2331
I here are the commands that I want to achieve in combined.
git -P branch
= show the list of branches and auto-exitgit branch --sort=-committerdate
= show the list of branches in descending order (from latest to oldest)My question is how to show the list of branches from latest to order that auto-exit according to terminal height (without pressing q)?
note: I don't want to show the entire list of branches, I just want to show according to terminal height.
Upvotes: 1
Views: 121
Reputation: 2331
in addition of @phd answer..
you can also add your own custom variable inside ~/.bashrc
file. append the variable.
export CUSTOMLINE=24
and follow the same command given by @phd
git branch --sort=-committerdate | head -$CUSTOMLINE
Upvotes: 1
Reputation: 94676
You already know the option -P
/--no-pager
so you can use it here:
git -P branch --sort=-committerdate
But that could produce long listing. If you want exactly one screen-high output you have to clip it. For example using head
git branch --sort=-committerdate | head -$LINES
Bash stores the current terminal height in environment variable $LINES
; if you don't use Bash you have to get the terminal height yourself. There is no need to use -P
as Git doesn't use pager when the output is not a terminal (it's a pipe in the command above).
Upvotes: 1