Move pacfiles script to a simpler shell function
parent
ac9a5cb5cb
commit
4045b211c5
|
@ -1,46 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
_usage () {
|
|
||||||
cat <<EOF
|
|
||||||
Usage: ${1##*/} [OPTIONS] PACKAGES
|
|
||||||
|
|
||||||
Display size of files in PACKAGES.
|
|
||||||
|
|
||||||
-h: Display this help.
|
|
||||||
-n: Sort by size.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
OPTION_SORT="cat"
|
|
||||||
|
|
||||||
while getopts ":hn" opt; do
|
|
||||||
case $opt in
|
|
||||||
h)
|
|
||||||
_usage "$0"
|
|
||||||
exit 1 ;;
|
|
||||||
n)
|
|
||||||
OPTION_SORT="sort -h" ;;
|
|
||||||
\?)
|
|
||||||
_usage "$0"
|
|
||||||
exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
shift $(($OPTIND - 1))
|
|
||||||
|
|
||||||
if [ $# -eq 0 ]; then
|
|
||||||
echo "Missing argument."
|
|
||||||
_usage "$0"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
! command -v pacman >/dev/null && echo "You need pacman to run this script." && exit 1
|
|
||||||
if [ $(pacman -Qq "$@" 2>/dev/null | wc -l) -eq 0 ]; then
|
|
||||||
echo "No valid package given." >&2
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
## We use "eval" to be compatible with non-POSIX wordsplitting (e.g. zsh).
|
|
||||||
## WARNING: this only works with GNU 'du'.
|
|
||||||
du -bch $(pacman -Qlq "$@" | grep -v '.*/$' | sort -u) 2>/dev/null | eval ${OPTION_SORT}
|
|
|
@ -223,6 +223,10 @@ if command -v pacman >/dev/null 2>&1; then
|
||||||
pli () {
|
pli () {
|
||||||
expac -t '%F %T' '%-8l %n' | sort -rn | head -${1:-30}
|
expac -t '%F %T' '%-8l %n' | sort -rn | head -${1:-30}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pacfiles () {
|
||||||
|
pacman -Qlq "$@" | grep -v '/$' | xargs du -cbh | sort -h
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##==============================================================================
|
##==============================================================================
|
||||||
|
|
Loading…
Reference in New Issue