1
0

zsh: misc git functions

This commit is contained in:
Konstantin Demin 2024-01-20 13:36:30 +03:00
parent 9bd1bb79ea
commit ad4acd935a
Signed by: krd
GPG Key ID: 1F33CB0BA4731BC6
2 changed files with 35 additions and 0 deletions

View File

@ -11,6 +11,7 @@
!/.config/zsh/alias/buildah.zsh
!/.config/zsh/alias/diff.zsh
!/.config/zsh/alias/directories.zsh
!/.config/zsh/alias/git.zsh
!/.config/zsh/alias/gpg.zsh
!/.config/zsh/alias/grep.zsh
!/.config/zsh/alias/history.zsh

34
.config/zsh/alias/git.zsh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/zsh
git-dir-usage() {
local d x p
d=$(__z_git rev-parse --git-dir) || return $?
x=$(__z_git rev-parse --path-format=absolute 2>/dev/null)
if [ -n "$x" ] ; then
## older git version which does not support "--path-format=absolute"
:
else
d=$(__z_git rev-parse --path-format=absolute --git-dir)
fi
case "$d" in
*/* ) p=${d%/*} ; d=${d##*/} ;;
esac
## ${p:+ env -C "$p" } du -cd2 "$d"
if [ -n "$p" ] ; then
env -C "$p" du -cd2 "$d"
else
du -cd2 "$d"
fi | grep -Ev '^[0-9]\s' | sort -Vk2
}
git-gc() {
git-dir-usage || return $?
echo
idle git gc "$@"
echo
git-dir-usage
}
git-gc-force() {
git-gc --aggressive --force
}