Skip to content

Commit

Permalink
pass certain commands and arguments to bare git
Browse files Browse the repository at this point in the history
Signed-off-by: Lucas Larson <LucasLarson@riseup.net>
  • Loading branch information
LucasLarson committed Jun 28, 2022
1 parent 66a437f commit cdeac31
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions custom/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -719,14 +719,21 @@ find_shell_scripts() {
unalias -- 'g' 2>/dev/null
compdef g='git' 2>/dev/null
g() {
command git rev-parse --is-inside-work-tree >/dev/null 2>&1 ||
return "${?:-1}"
# if first argument is a file, then perform `git status` on it
if test -e "${1-}"; then
command git status -- "$@"
else
command git "${@:-status}"
fi
case "${1-}" in
clone | config | help | init | version | -*)
command git "$@"
;;
*)
command git rev-parse --is-inside-work-tree >/dev/null 2>&1 ||
return "${?:-1}"
# if first argument is a file, then perform `git status` on it
if test -e "${1-}"; then
command git status -- "$@"
else
command git "${@:-status}"
fi
;;
esac
}
alias g.='command git status .'
alias guo='command git status --untracked-files=no'
Expand Down

0 comments on commit cdeac31

Please sign in to comment.