git-fast
A little utility to query various info about your Git repository in a compact format and in a fastest possible way.
The Problem
Computers are blazingly fast today but disks and filesystems are still not. So are the Git repositories, especially when they're large enough. Commands like git diff
and git status
could be really slow and it causes a horrific UX. But what if you just don't need a full git status
of git diff
output every time? What if you don't need a full list of changed/staged files and all you need to know that at least one such file exists?
Queries like "does anything changed in my repo?", "is my index empty or not?" often occur when you are building a fancy prompt for your Shell where you want to report a git status
info in a compact form with some coloring and unicode icons. Examples are Pure, Agnoster theme and many others.
When git status
call is slow, render of shell prompt is also slow. Some advanced prompts like Pure mitigate this problem by performing git queries asynchronously using zsh-async
and though such a technique significantly improves the UX the problem still exists. We still can do better.
Commands
git-fast status
Command git-fast status
is like git status
but it doesn't print anything. Instead, it returns the status in its exit code!
Code |
Code (bin) |
Untracked files |
Unstaged changes |
Staged changes |
0 |
00000000 |
no |
no |
no |
1 |
00000001 |
yes |
no |
no |
2 |
00000010 |
no |
yes |
no |
3 |
00000011 |
yes |
yes |
no |
4 |
00000100 |
no |
no |
yes |
5 |
00000101 |
yes |
no |
yes |
6 |
00000110 |
no |
yes |
yes |
7 |
00000111 |
yes |
yes |
yes |
125 |
|
error |
error |
error |
Check git-fast status --help
for more info.
Installation
go install github.com/marshall-lee/git-fast@latest