From 1d2b6827a7d713966a05c24dd4b471e6f376c026 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 12 May 2014 12:18:33 +0200 Subject: [PATCH] zshrc: extend dchange() to support apt-get and multiple package names Since apt v0.8.11 it's possible to use "apt-get changelog $package" as well. While at it support displaying changelogs for multiple packages. --- etc/zsh/zshrc | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index fc97062..f95045a 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2544,26 +2544,31 @@ sll() { # PAGER='less -Mr' - If so, the use of $PAGER here needs fixing # with respect to wordsplitting. (ie. ${=PAGER}) if check_com -c $PAGER ; then - #f3# View Debian's changelog of a given package + #f3# View Debian's changelog of given package(s) dchange() { emulate -L zsh - if [[ -r /usr/share/doc/$1/changelog.Debian.gz ]] ; then - $PAGER /usr/share/doc/$1/changelog.Debian.gz - elif [[ -r /usr/share/doc/$1/changelog.gz ]] ; then - $PAGER /usr/share/doc/$1/changelog.gz - else - if check_com -c aptitude ; then - echo "No changelog for package $1 found, using aptitude to retrieve it." - if isgrml ; then - aptitude -t unstable changelog $1 + [[ -z "$1" ]] && printf 'Usage: %s \n' "$0" && return 1 + + local package + for package in "$@" ; do + if [[ -r /usr/share/doc/${package}/changelog.Debian.gz ]] ; then + $PAGER /usr/share/doc/${package}/changelog.Debian.gz + elif [[ -r /usr/share/doc/${package}/changelog.gz ]] ; then + $PAGER /usr/share/doc/${package}/changelog.gz + elif [[ -r /usr/share/doc/${package}/changelog ]] ; then + $PAGER /usr/share/doc/${package}/changelog + else + if check_com -c aptitude ; then + echo "No changelog for package $package found, using aptitude to retrieve it." + aptitude changelog "$package" + elif check_com -c apt-get ; then + echo "No changelog for package $package found, using apt-get to retrieve it." + apt-get changelog "$package" else - aptitude changelog $1 + echo "No changelog for package $package found, sorry." fi - else - echo "No changelog for package $1 found, sorry." - return 1 fi - fi + done } _dchange() { _files -W /usr/share/doc -/ } compdef _dchange dchange -- 2.1.4