The git Script I Use Everyday, All the Time
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 <commit>
to display a commit:
gs <commit>
I wrote it as a fish shell function, but it should be easy to convert to a shell script 1:
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 ")'
-
Except maybe for autocompletion. That’s why I use fish shell ↩