From: Michael Prokop Date: Fri, 15 Nov 2019 16:47:40 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/github/pr/87' X-Git-Tag: v0.16.2~5 X-Git-Url: https://git.grml.org/?a=commitdiff_plain;h=7c81531c90c9fb23296f4d297bc2f4a0772793af;hp=1be4f3ede299206ae9c5f7558263eef7b7314fcc;p=grml-etc-core.git Merge remote-tracking branch 'origin/github/pr/87' --- diff --git a/etc/zsh/zshrc b/etc/zsh/zshrc index 0a7d730..2969729 100644 --- a/etc/zsh/zshrc +++ b/etc/zsh/zshrc @@ -2928,9 +2928,6 @@ 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 () { @@ -2938,13 +2935,28 @@ if check_com -c $PAGER ; then [[ -z "$1" ]] && printf 'Usage: %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."