dotfiles/.config/zsh/functions/showebuild

21 lines
500 B
Plaintext
Raw Normal View History

#!/usr/bin/env zsh
# Show either installed, newest non-live or newest ebuild
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
autoload -U die
[[ ${ARGC} -eq 0 ]] && die 1 "Usage: ${0} <PKG>"
local pkg=${1}
local ebuild=$(qwhich --vdb --latest ${pkg})
if [[ -z ${ebuild} ]]; then
for ebuild in $(qwhich --tree ${pkg} | sort --numeric-sort --reverse); do
[[ ${ebuild} =~ '9999(-r\d+)?\.ebuild$' ]] || break
done
fi
[[ -z ${ebuild} ]] && die 1 "Package not found"
less ${ebuild}