diff --git a/.config/zsh/completions/_showebuild b/.config/zsh/completions/_showebuild new file mode 100644 index 0000000..aa09904 --- /dev/null +++ b/.config/zsh/completions/_showebuild @@ -0,0 +1,9 @@ +#compdef showebuild + +autoload -U _gentoo_packages + +_arguments '*:package:_gentoo_packages available' + +# Local Variables: +# mode: shell-script +# End: diff --git a/.config/zsh/functions/showebuild b/.config/zsh/functions/showebuild new file mode 100755 index 0000000..fb3ec7c --- /dev/null +++ b/.config/zsh/functions/showebuild @@ -0,0 +1,20 @@ +#!/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} " + +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}