Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/github/pr/87'
Browse files Browse the repository at this point in the history
  • Loading branch information
mika committed Nov 15, 2019
2 parents 1be4f3e + 675c85b commit 7c81531
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions etc/zsh/zshrc
Expand Up @@ -2928,23 +2928,35 @@ function sll () {
return ${RTN}
}

# TODO: Is it supported to use pager settings like this?
# 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 given package(s)
function dchange () {
emulate -L zsh
[[ -z "$1" ]] && printf 'Usage: %s <package_name(s)>\n' "$0" && return 1

local package

# `less` as $PAGER without e.g. `|lesspipe %s` inside $LESSOPEN can't properly
# read *.gz files, try to detect this to use vi instead iff available
local viewer

if [[ ${$(typeset -p PAGER)[2]} = -a ]] ; then
viewer=($PAGER) # support PAGER=(less -Mr) but leave array untouched
else
viewer=(${=PAGER}) # support PAGER='less -Mr'
fi

if [[ ${viewer[1]:t} = less ]] && [[ -z "${LESSOPEN}" ]] && check_com vi ; then
viewer='vi'
fi

for package in "$@" ; do
if [[ -r /usr/share/doc/${package}/changelog.Debian.gz ]] ; then
$PAGER /usr/share/doc/${package}/changelog.Debian.gz
$viewer /usr/share/doc/${package}/changelog.Debian.gz
elif [[ -r /usr/share/doc/${package}/changelog.gz ]] ; then
$PAGER /usr/share/doc/${package}/changelog.gz
$viewer /usr/share/doc/${package}/changelog.gz
elif [[ -r /usr/share/doc/${package}/changelog ]] ; then
$PAGER /usr/share/doc/${package}/changelog
$viewer /usr/share/doc/${package}/changelog
else
if check_com -c aptitude ; then
echo "No changelog for package $package found, using aptitude to retrieve it."
Expand Down

0 comments on commit 7c81531

Please sign in to comment.