I’ve been using git status
for quite a long time now. Let’s make it better.
My ~/.gitconfig
has had:
[alias]
s = status
d = diff
l = log --show-signature
for as long as I can remember. They’ve served me well.
In one of my projects, I occasionally
have a bunch of untracked files, particularly when I’m hacking on something new
that isn’t committed yet. This may include notes, new tests, and so on. My
terminal is usually between 24
and 37
lines tall. (Eg: run tput lines
.) If
there’s a lot of untracked stuff here, I’ll quickly go over this limit and have
to scroll to see what’s staged and so on.
Git can display the status in columns like ls
does. I use
git status --column=nodense
. I don’t like to see column mode when I don’t have
to. Git doesn’t support doing that magic so I built it.
Add the following to your ~/.gitconfig
:
[alias]
#s = status # goodbye old friend
s = "!f() { rows=$(tput lines); lines=$(git status | wc -l); if [ \"$lines\" -gt \"$rows\" ]; then git status --column=nodense; else git status; fi; }; f"
Now whenever you run git s
, you’ll only see the columns when it won’t fit.
Save seconds of keystrokes, and the hours will take care of themselves.
Enterprise support, training, and consulting are all available.
Happy Hacking,
James
You can follow James on Mastodon for more frequent updates and other random thoughts.
You can follow James on Twitter for more frequent updates and other random thoughts.
You can support James on GitHub if you'd like to help sustain this kind of content.
You can support James on Patreon if you'd like to help sustain this kind of content.
Your comment has been submitted and will be published if it gets approved.
Click here to see the patch you generated.
Comments
Nothing yet.
Post a comment