The git Script I Use Everyday, All the Time

Boon aka Hwee-Boon Yar March 7, 2024
Source

One of my most used Git script is gs. It's an overloaded function that does the following:

RUNS GIT STATUS TO LOOK AT WORKING TREE STATUS:

gs

RUNS GIT STATUS <FILE NAME/PATH> TO ONLY LOOK AT A FILE:

gs <file name/path>

RUNS GIT SHOW TO DISPLAY A COMMIT:

gs

I wrote it as a fish shell function, but it should be easy to convert to a shell script [^completion]:

function gs if not string length -q -- "$argv" git status -s else if test -e "$argv" git status -s $argv else #--ext-diff so external diff tool specified in git config --get diff.external is used (it's only automatically applied only for git diff) git show --ext-diff $argv end end end

complete -c gs -a '(complete -C "git show ")'

[^completion]: Except maybe for autocompletion. That's why I use fish shell

Discussion in the ATmosphere

Loading comments...