Git Log in ZSH Terminal

git, terminal, zsh

Solution

with tmux, you can split-pane `zsh -c while :; do sleep 60; git log ...; done` and this should achieve an automagically refreshing git log output in a pane.

supply [-vh] [percent] to split-pane to split vert or horiz with a given percent of the terminal. iirc, it splits from bottom and/or right side of terminal, so adjust percentage accordingly.

this should have the desired effect of having git log in a pane beside $EDITOR (or below), with appropriate dimensions and automagically refresh every minute. feel free to alter or clean up syntax to suit your needs.

EDIT: respawning a pane in tmux can be done with the tmux builtin `respawn-pane`. you can bind a key something like this to get a simple shortcut

bind-key -n M-r respawn-pane -t git:0.1 [command]

in this example, i assume 3 things. first, that you have a named tmux session (named git, but this is arbitrary and to your choosing by using `rename-session` in tmux or by launching the session with `new-session -s name`). second, that the git log (which is what we want to refresh) is at window of index 0 (this is the first window opened in a session, by default, unless you set `base-index` to else) and the pane of index 1.

so here, it respawns the second pane of the first window in the "git" session by pressing alt-r. if you use the loop i provided before, this is unnecessary to do because the log will refresh itself after each sleep. that may be considered wasteful to some, so you may arbitrarily decide to respawn this pane at your whim instead.

[command] is optional. tmux's `respawn-pane` will execute the command that was given when the pane was spawned at first. in this example, it will be the `while` loop by default. if you skip the loop and instead just use `split-pane [-hv] [percent] "git log ..."` then do not provide the optional command parameter as the pane will run it for you smartly. providing the command parameter to `respawn-pane` will take precedence over the initial command used when spawning the pane.

finally, if you do not provide the command parameter to `split-pane` initially, tmux will run whatever value `default-command` is.

so there you have an overly verbose explanation of how to do what this video does in multiple ways.

Problem

I remember in a Git-tutorial video that the user's terminal (probably ZSH) was split into two; one for the standard terminal commands, and below that there was something like Git log graphical representation. It was always visible at the bottom of the terminal with nice colors. . How is it possible to split the terminal screen into two and display Git log (something like `git log --pretty=format:'%h : %s' --graph`) on the terminal screen? UPDATE: I found the video on Vimeo, http://vimeo.com/16018419. I am trying to do the exact same setup on my ZSH terminal.

Original source