commit 97819541aca9ccc81651d7d9b3c9c623610bf087
parent 6d9cf6aeed35fdd2e5d27b3830fb257ee902a987
Author: hhvn <dev@hhvn.uk>
Date: Wed, 5 May 2021 18:40:37 +0100
.c/g/config .c/g/disk-usage .c/g/m/m/git-du.1: add du command
Diffstat:
3 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/.config/git/config b/.config/git/config
@@ -15,6 +15,7 @@
pa = !sh ~/.config/git/push --all
ef = !sh ~/.config/git/effort
fi = !sh ~/.config/git/find
+ du = !sh ~/.config/git/disk-usage
br = branch
se = send-email
ad = add
diff --git a/.config/git/disk-usage b/.config/git/disk-usage
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+[ "$@" = "" ] && args=-h
+
+[ "$@" != "" ] &&
+ [ "$@" != "-s" ] &&
+ [ "$@" != "-h" ] &&
+ [ "$@" != "-sh" ] &&
+ echo "usage: git du [-sh]" &&
+ exit 1
+
+(
+ [ -d ./.git ] && du "${args:-$@}" .git || du "${args:-$@}" .
+) | tail -n 1 | awk '{print "Repo: " $1}'
diff --git a/.config/git/man/man1/git-du.1 b/.config/git/man/man1/git-du.1
@@ -0,0 +1,20 @@
+.Dd 27 Apr 2021
+.Dt git-du 1
+.Os hhvn-git(7)
+.Sh Name
+.Nm git-du
+.Nd calculate size of git repo (excl. checked out/untracked files)
+.Sh SYNOPSIS
+.Nm git du
+.Op Fl sh
+.Sh OPTIONS
+Assumes -h by default, use:
+.D1 git du ''
+or -s only to not use -h.
+.Op Ar author
+.Sh BUGS
+When invoked with -h via git, the following is shown:
+.D1 'du' is aliased to '!sh ~/.config/git/disk-usage'
+.D1 Usual output here...
+.Sh AUTHOR
+.An hhvn Aq Mt dev@hhvn.uk .