Inverted git log --graph
Using git log --graph is nice, but I dislike that the most relevant commits, are shown at the top of
the terminal screen. If your terminal scrolls some lines after quitting the graph pager, those commits
will not be visible and you will need to scroll up.
Unfortunately --graph and --reverse cannot be used together.
You can use tac to invert the output, however the graph needs some adjustments to be properly drawn.
The script below substitutes:
| From | To |
|---|---|
| \ | / |
| / | \ |
| _ | ̅ |
That will make the graph be properly shown in its reversed form.
| |
Then we can combine the script with tac and less, to have essentially the same behavior as the original git log --graph, but inverted:
| |
Bonus Tip: ZSH Completions on alias
If you use just an alias, in your config you’ll lose the completions provided by zsh. If you set up the alias as a function, you can retain completions. For example, when you want to look at a few branches, the git completions will show the available branches, and if you use fzf, you can easily select one.
For zsh to provide completions on the new commands you need to use a function and compdef. In your .zshrc, place the function definitions and after them, use compdef:
| |
For extra reference you can check my nixos-config.
Here’s an example of what it looks like:
