#!/usr/bin/env bash

# Return a list of packages sorted by size

(echo PACKAGE SIZE; \
  for A in /var/lib/pacman/local/*/desc; do
    (sed -n 2p $A; (grep '^%SIZE%$' $A -A1 | tail -1)) | tr '\n' ' '; echo
  done \
  | sort -nrk2) \
| column -t