The command âLessâ performs differently when invoked from Bash vs. from Git
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
When I view a large diff with git diff
, it gets paged with less
. This is confirmed by opening another window and checking data from ps -aux
and /proc
.
However, when less
is invoked by Git
, it does not revert the terminal content to its previous state after hitting q
(the diff content remains in terminal), but when I run the command:
git diff commit1 commit2 --color | less -R
and quit less
with the key q
, the content disappears and the terminal reverts to the previous state.
More interestingly, when I export PAGER=less LESS='-R'
, and invoke git diff
(or any other command that calls a pager), the command less
behave the same as if invoked directly from Bash shell.
Below is a brief screenshot showing my problem. On the left pane, the commands are executed as follows:
unset PAGER GIT_PAGER LESS
git diff HEAD^ HEAD
On the right pane, I can see the commands. The latest commit was 100+
lines of y
were written to a file. On both panes less
can be exited with the key q
.
Would you please explain what is different and why?
git less
add a comment |Â
up vote
1
down vote
favorite
When I view a large diff with git diff
, it gets paged with less
. This is confirmed by opening another window and checking data from ps -aux
and /proc
.
However, when less
is invoked by Git
, it does not revert the terminal content to its previous state after hitting q
(the diff content remains in terminal), but when I run the command:
git diff commit1 commit2 --color | less -R
and quit less
with the key q
, the content disappears and the terminal reverts to the previous state.
More interestingly, when I export PAGER=less LESS='-R'
, and invoke git diff
(or any other command that calls a pager), the command less
behave the same as if invoked directly from Bash shell.
Below is a brief screenshot showing my problem. On the left pane, the commands are executed as follows:
unset PAGER GIT_PAGER LESS
git diff HEAD^ HEAD
On the right pane, I can see the commands. The latest commit was 100+
lines of y
were written to a file. On both panes less
can be exited with the key q
.
Would you please explain what is different and why?
git less
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When I view a large diff with git diff
, it gets paged with less
. This is confirmed by opening another window and checking data from ps -aux
and /proc
.
However, when less
is invoked by Git
, it does not revert the terminal content to its previous state after hitting q
(the diff content remains in terminal), but when I run the command:
git diff commit1 commit2 --color | less -R
and quit less
with the key q
, the content disappears and the terminal reverts to the previous state.
More interestingly, when I export PAGER=less LESS='-R'
, and invoke git diff
(or any other command that calls a pager), the command less
behave the same as if invoked directly from Bash shell.
Below is a brief screenshot showing my problem. On the left pane, the commands are executed as follows:
unset PAGER GIT_PAGER LESS
git diff HEAD^ HEAD
On the right pane, I can see the commands. The latest commit was 100+
lines of y
were written to a file. On both panes less
can be exited with the key q
.
Would you please explain what is different and why?
git less
When I view a large diff with git diff
, it gets paged with less
. This is confirmed by opening another window and checking data from ps -aux
and /proc
.
However, when less
is invoked by Git
, it does not revert the terminal content to its previous state after hitting q
(the diff content remains in terminal), but when I run the command:
git diff commit1 commit2 --color | less -R
and quit less
with the key q
, the content disappears and the terminal reverts to the previous state.
More interestingly, when I export PAGER=less LESS='-R'
, and invoke git diff
(or any other command that calls a pager), the command less
behave the same as if invoked directly from Bash shell.
Below is a brief screenshot showing my problem. On the left pane, the commands are executed as follows:
unset PAGER GIT_PAGER LESS
git diff HEAD^ HEAD
On the right pane, I can see the commands. The latest commit was 100+
lines of y
were written to a file. On both panes less
can be exited with the key q
.
Would you please explain what is different and why?
git less
git less
edited 5 hours ago
Goro
2,29641849
2,29641849
asked 5 hours ago
iBug
688421
688421
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Documentation:
When the
LESS
environment variable is unset, Git sets it toFRX
(ifLESS
environment variable is set, Git does not change it at all).
The -X
(--no-init
) option is responsible for not clearing terminal after exit of less
.
New contributor
Wow, great answer! I'd like to know if there's agit config
to change this behavior (change theLESS
environment that Git sets).
â iBug
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
I got Less 530 from FSF and compiled it myself. Nowless -FR
is very good to have. Thank you again!
â iBug
24 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Documentation:
When the
LESS
environment variable is unset, Git sets it toFRX
(ifLESS
environment variable is set, Git does not change it at all).
The -X
(--no-init
) option is responsible for not clearing terminal after exit of less
.
New contributor
Wow, great answer! I'd like to know if there's agit config
to change this behavior (change theLESS
environment that Git sets).
â iBug
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
I got Less 530 from FSF and compiled it myself. Nowless -FR
is very good to have. Thank you again!
â iBug
24 mins ago
add a comment |Â
up vote
4
down vote
accepted
Documentation:
When the
LESS
environment variable is unset, Git sets it toFRX
(ifLESS
environment variable is set, Git does not change it at all).
The -X
(--no-init
) option is responsible for not clearing terminal after exit of less
.
New contributor
Wow, great answer! I'd like to know if there's agit config
to change this behavior (change theLESS
environment that Git sets).
â iBug
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
I got Less 530 from FSF and compiled it myself. Nowless -FR
is very good to have. Thank you again!
â iBug
24 mins ago
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Documentation:
When the
LESS
environment variable is unset, Git sets it toFRX
(ifLESS
environment variable is set, Git does not change it at all).
The -X
(--no-init
) option is responsible for not clearing terminal after exit of less
.
New contributor
Documentation:
When the
LESS
environment variable is unset, Git sets it toFRX
(ifLESS
environment variable is set, Git does not change it at all).
The -X
(--no-init
) option is responsible for not clearing terminal after exit of less
.
New contributor
New contributor
answered 2 hours ago
PetSerAl
1562
1562
New contributor
New contributor
Wow, great answer! I'd like to know if there's agit config
to change this behavior (change theLESS
environment that Git sets).
â iBug
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
I got Less 530 from FSF and compiled it myself. Nowless -FR
is very good to have. Thank you again!
â iBug
24 mins ago
add a comment |Â
Wow, great answer! I'd like to know if there's agit config
to change this behavior (change theLESS
environment that Git sets).
â iBug
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
I got Less 530 from FSF and compiled it myself. Nowless -FR
is very good to have. Thank you again!
â iBug
24 mins ago
Wow, great answer! I'd like to know if there's a
git config
to change this behavior (change the LESS
environment that Git sets).â iBug
2 hours ago
Wow, great answer! I'd like to know if there's a
git config
to change this behavior (change the LESS
environment that Git sets).â iBug
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
@iBug Looks like it is baked into the source. Thus you need to build your own Git to change that.
â PetSerAl
2 hours ago
I got Less 530 from FSF and compiled it myself. Now
less -FR
is very good to have. Thank you again!â iBug
24 mins ago
I got Less 530 from FSF and compiled it myself. Now
less -FR
is very good to have. Thank you again!â iBug
24 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f469360%2fthe-command-less-performs-differently-when-invoked-from-bash-vs-from-git%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password