git-log in eshell
I'm trying to run git commands in eshell. When I run:
git log -p
it will look like this:
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:
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.
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
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.
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.
disable git's built-in pager by setting it to cat
:
git config --global core.pager cat
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.
精彩评论