Anyone know how to get git working properly with less and vim? Specifically:
* less does not "clear" (revert) the screen properly after commands like "git log" and "git diff" * vim isn't using the git extensions/file types for commands like "git commit"
Both of these work properly in Gentoo (and vim -- but not less -- works properly in Ubuntu), but it's not obvious to me what's different between the distros to account for the differing behavior...
Brian Ericson wrote:
Anyone know how to get git working properly with less and vim? Specifically:
- less does not "clear" (revert) the screen properly after commands
like "git log" and "git diff"
[...]
Both of these work properly in Gentoo (and vim -- but not less -- works properly in Ubuntu), but it's not obvious to me what's different between the distros to account for the differing behavior...
The difference is likely that Fedora is shipping a more recent version of git than Ubuntu and upstream git has seen a few changes regarding the pager handling.
Check out the core.pager setting in the git-config manpage. You can set this a number of ways, using the LESS or GIT_PAGER environment variables, or the core.pager config setting. By default, git pass the options FSRX to less. The -X option is what prevents less from clearing the screen, but using -F also causes this in my testing (which I found confusing...).
If it were me, I'd set the LESS variable and exclude FX, e.g:
export LESS="-RS"
(See the less man page for the options you might want to set.
If you use GIT_PAGER or the core.pager setting, you will have to use slightly odd syntax to override the LESS environment var that git will set, e.g.:
export GIT_PAGER='less -+$LESS -RS'
or
git config --global core.pager 'less -+$LESS -RS'
This is described in the git-config manpage.
- vim isn't using the git extensions/file types for commands like "git
commit"
On F-10, this should "Just Work" as vim-7.2 has the needed syntax files included. Is your EDITOR var set to vim?
On Fri, May 29, 2009 at 10:47:08AM -0500, Brian Ericson wrote:
Anyone know how to get git working properly with less and vim? Specifically:
- less does not "clear" (revert) the screen properly after commands like
"git log" and "git diff"
- vim isn't using the git extensions/file types for commands like "git
commit"
Both of these work properly in Gentoo (and vim -- but not less -- works properly in Ubuntu), but it's not obvious to me what's different between the distros to account for the differing behavior...
Funny, I would look at clearing the screen after a git log to be awful, since I frequently need the commit name for the following command.
I found what I think is the appropriate info in 'man git-config' under the 'core.pager' setting.
Paul W. Frields wrote:
Funny, I would look at clearing the screen after a git log to be awful, since I frequently need the commit name for the following command.
:-) That's part of why finding the right default beharior upstream is so difficult.
Thanks for both the "less" guidance and the EDITOR tip!
Assigning the EDITOR to vim fixes the "git commit" issue (Gentoo assigns EDITOR by default).
I think I've got "less" figured out -- Gentoo exports LESS='-R -M --shift 5' (which overrides Git's value/default value). I'd gotten far enough to see that this variable affected git's paging in Gentoo before posting, but when I tried it on Fedora mistakenly set it without exporting it, so it didn't carry through to git's invocation of less (colleague of mine laughed and said he likes to ask that as an interview question -- "what's the difference between a shell variable and an envirnoment variable?").
Your mentioning of Fedora's Git version (which is much newer than Ubuntu's 1.6.0.4) reminds me that I'm pining for either Fedora's being at 1.6.3.1 (like Gentoo is) or Git's on git.repo to update their repodata so I can use theirs instead.
Also, only marginally related: tracking this down, I noticed that /usr/share/doc/git-<version>/config.txt is fontified in Vim when using Gentoo but not when using Fedora. Something else to figure out... (Who knew distributions could be so markedly different? ;) )
On 05/29/2009 11:55 AM, Todd Zullinger wrote:
Brian Ericson wrote:
Anyone know how to get git working properly with less and vim? Specifically:
- less does not "clear" (revert) the screen properly after commands
like "git log" and "git diff"
[...]
Both of these work properly in Gentoo (and vim -- but not less -- works properly in Ubuntu), but it's not obvious to me what's different between the distros to account for the differing behavior...
The difference is likely that Fedora is shipping a more recent version of git than Ubuntu and upstream git has seen a few changes regarding the pager handling.
Check out the core.pager setting in the git-config manpage. You can set this a number of ways, using the LESS or GIT_PAGER environment variables, or the core.pager config setting. By default, git pass the options FSRX to less. The -X option is what prevents less from clearing the screen, but using -F also causes this in my testing (which I found confusing...).
If it were me, I'd set the LESS variable and exclude FX, e.g:
export LESS="-RS"
(See the less man page for the options you might want to set.
If you use GIT_PAGER or the core.pager setting, you will have to use slightly odd syntax to override the LESS environment var that git will set, e.g.:
export GIT_PAGER='less -+$LESS -RS'
or
git config --global core.pager 'less -+$LESS -RS'
This is described in the git-config manpage.
- vim isn't using the git extensions/file types for commands like "git
commit"
On F-10, this should "Just Work" as vim-7.2 has the needed syntax files included. Is your EDITOR var set to vim?
I'd gotten used to everything (except for, oddly enough, status) paging and use "git --no-pager" when I explicitly don't want it to page.
On 05/29/2009 12:49 PM, Paul W. Frields wrote:
On Fri, May 29, 2009 at 10:47:08AM -0500, Brian Ericson wrote:
Anyone know how to get git working properly with less and vim? Specifically:
- less does not "clear" (revert) the screen properly after commands like
"git log" and "git diff"
- vim isn't using the git extensions/file types for commands like "git
commit"
Both of these work properly in Gentoo (and vim -- but not less -- works properly in Ubuntu), but it's not obvious to me what's different between the distros to account for the differing behavior...
Funny, I would look at clearing the screen after a git log to be awful, since I frequently need the commit name for the following command.
I found what I think is the appropriate info in 'man git-config' under the 'core.pager' setting.
Brian Ericson wrote:
Thanks for both the "less" guidance and the EDITOR tip!
Sure thing.
(colleague of mine laughed and said he likes to ask that as an interview question -- "what's the difference between a shell variable and an envirnoment variable?").
:)
Your mentioning of Fedora's Git version (which is much newer than Ubuntu's 1.6.0.4) reminds me that I'm pining for either Fedora's being at 1.6.3.1 (like Gentoo is) or Git's on git.repo to update their repodata so I can use theirs instead.
If you want, you can rebuild the srpm I've been using:
http://tmz.fedorapeople.org/tmp/git-1.6.3.1-1.fc10.src.rpm
That should rebuild in mock for EL-4 up through rawhide. Do keep in mind that it's not an official package and that you'd have to take some manual steps to update to an official 1.6.3.1-1 package for Fedora, if we release one. (Chances are a newer git version will be out before it matters, but it's something to think about.)
I've held off updating rawhide/F-11 as a 1.6.3.2 is possible before (or soon after) F-11 is released and I've been debating whether we should bother pushing a 1.6.2.5 update to F-11 and then a 1.6.3.x sometime after the 1.6.3.x series has had a little time in rawhide.
Well, that and I've just not had as much time to do packaging the past few weeks. :)
I think git log is using more, not less .. that's why your console is not cleaned up.
Cheers, Jan
Jan te Beest (jteb) wrote:
I think git log is using more, not less .. that's why your console is not cleaned up.
Not by default. Git uses less, unless you set the PAGER or GIT_PAGER environment variables, or set the core.pager setting in git's config.