From 08c8ac784d1ae952abb0a02082f8e76bcdcc347e Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Thu, 9 Mar 2023 23:24:39 +0000 Subject: [PATCH] feat(git): add git-largest-objects helper --- zsh/git.zsh | 13 +++++++++++++ zshrc | 1 + 2 files changed, 14 insertions(+) create mode 100644 zsh/git.zsh diff --git a/zsh/git.zsh b/zsh/git.zsh new file mode 100644 index 0000000..8a713a9 --- /dev/null +++ b/zsh/git.zsh @@ -0,0 +1,13 @@ +# +# git +# + +# Stolen from: https://stackoverflow.com/a/42544963 +git-largest-objects() { + git rev-list --objects --all | + git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | + sed -n 's/^blob //p' | + sort --numeric-sort --key=2 | + cut -c 1-12,41- | + $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest +} diff --git a/zshrc b/zshrc index 52cfc5e..c63ee8c 100644 --- a/zshrc +++ b/zshrc @@ -136,6 +136,7 @@ source "$DOTZSH/tmux.zsh" # Development source "$DOTZSH/containers.zsh" source "$DOTZSH/golang.zsh" +source "$DOTZSH/git.zsh" source "$DOTZSH/google-cloud.zsh" source "$DOTZSH/kubernetes.zsh" source "$DOTZSH/nodejs.zsh"