git-log in eshell
Asked Answered
I

5

11

I'm trying to run git commands in eshell. When I run:

git log -p

it will look like this:

git-log in eshell

Notice that ^[[k before the cursor. Arrow key down does not work, it will gives error says 'Not found'. You can see that at minibuffer. The only way to scroll down is to use RETURN key, and it looks quite messy:

git-log in eshell -- scrolling

My $TERM is set to eterm, and I tried ansi too. They are the same. Anyone has experienced this before?

Thanks

Edit:

I have a way to work this around. I created this function:

(defun eshell/git (&rest args)
     (apply 'eshell-exec-visual (cons "git" args)))

So every time when I run git command, it will launch the output in a *git* buffer.

If you have other ways, please let me know as well.

Intracutaneous answered 20/4, 2011 at 4:42 Comment(0)
G
4

You can scroll only with RETURN because pager is used. You can either disable it permanently by changing git's core.pager config option, or you can disable it temporary by setting GIT_PAGER environment variable to empty string. Another possible source of problem - ^[ secuences, that are used to switch colors. You can disable them with --no-color option for git log command

Grindelia answered 20/4, 2011 at 13:38 Comment(1)
GIT_PAGER works great, now I can do proper grep in *eshell*. --no-color doesn't seems to help, but since there is no pager, they are not showing up anymore. Thanks.Intracutaneous
C
3

Have you tried using Magit? It integrates git into your normal Emacs workflow. I can't tell you much about it because I've only just started using Emacs, and I'm still trying to learn the basics. Magit seems really nice though. Install magit, open a file in your repo, and run M-x magit-log-long, that will create a buffer with the output of git log with an ascii history graph. I'm fairly sure that you can also checkout old commits from that buffer, but you should read the manual to be sure.

Chatterbox answered 27/4, 2011 at 15:4 Comment(0)
V
3

You must have colors turned on in git and that specific pseudo-terminal doesn't work in color. Try using m-x ansi-term. It supports colors and is generally more terminal-like.

Or you can try this hook:

 (add-hook 'eshell-preoutput-filter-functions
           'ansi-color-filter-apply)

Referenced from here.

Vestal answered 1/5, 2011 at 6:15 Comment(1)
for the record, i have OP's problem as well, my ansi colors work fine, the problem is git's built in pager doesn't play nice with shell-mode and eshell's limited terminal functionalityLikeness
L
1

disable git's built-in pager by setting it to cat:

git config --global core.pager cat
Likeness answered 4/9, 2012 at 13:21 Comment(1)
This isn't a very satisfactory solution if one uses git from both eshell and a more conventional shell.Kazan
O
0

The vc-print-root-log command (C-x v L) prints a nicely formatted git log in a read-only buffer that you can search, diff and display commits from.

Ocean answered 19/9, 2017 at 8:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.