From abf19647c73f2ee36359f5080c1a5d61a09f3d8c Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 9 Apr 2022 22:38:01 +0200 Subject: [PATCH] Add showebuild function Show either installed, newest non-live or newest ebuild in less --- .config/zsh/completions/_showebuild | 9 +++++++++ .config/zsh/functions/showebuild | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .config/zsh/completions/_showebuild create mode 100755 .config/zsh/functions/showebuild 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}