Skip to content

Commit

Permalink
zshrc: extend dchange() to support apt-get and multiple package names
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mika committed May 12, 2014
1 parent 8875863 commit 86d91f2
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions etc/zsh/zshrc
Expand Up @@ -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 <package_name(s)>\n' "$0" && return 1

for file in "$@" ; do
if [[ -r /usr/share/doc/${file}/changelog.Debian.gz ]] ; then
$PAGER /usr/share/doc/${file}/changelog.Debian.gz
elif [[ -r /usr/share/doc/${file}/changelog.gz ]] ; then
$PAGER /usr/share/doc/${file}/changelog.gz
elif [[ -r /usr/share/doc/${file}/changelog ]] ; then
$PAGER /usr/share/doc/${file}/changelog
else
if check_com -c aptitude ; then
echo "No changelog for package(s) $file found, using aptitude to retrieve it."
aptitude changelog "$file"
elif check_com -c apt-get ; then
echo "No changelog for package(s) $file found, using apt-get to retrieve it."
apt-get changelog "$file"
else
aptitude changelog $1
echo "No changelog for package(s) $file found, sorry."
return 1
fi
else
echo "No changelog for package $1 found, sorry."
return 1
fi
fi
done
}
_dchange() { _files -W /usr/share/doc -/ }
compdef _dchange dchange
Expand Down

0 comments on commit 86d91f2

Please sign in to comment.