From 3e30bb71a0f86a91ba9198dd2a4f100a01629878 Mon Sep 17 00:00:00 2001 From: don philipe Date: Tue, 2 Sep 2025 13:23:45 +0200 Subject: [PATCH] Add zsh function to list all git blobs in a repo --- .zsh-custom/functions.zsh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.zsh-custom/functions.zsh b/.zsh-custom/functions.zsh index a3fa96b..9cedf83 100644 --- a/.zsh-custom/functions.zsh +++ b/.zsh-custom/functions.zsh @@ -59,6 +59,18 @@ m4a2mp3() done } +# Show all blob objects in repo sorted from smalles to largest +# https://stackoverflow.com/a/42544963 +git-blobs() +{ + git rev-list --objects --all --missing=print | + 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 +} + # show the current mode: #PR_VIMODE="#" #function zle-keymap-select