__fish_print_packages: Fix apt

On my system this printed just "Description:" without any additional
characters, so this awkward `sed` didn't match and produced *all
packages on one line*.

Tbh this should probably be rewritten, but first we'd have to find a
way to get proper output here.
This commit is contained in:
Fabian Homborg
2020-06-08 18:32:52 +02:00
parent 983f9eaa50
commit a4a4a2e1b6

View File

@@ -23,11 +23,11 @@ function __fish_print_packages
# (It is safe to use `sed -r` here as we are guaranteed to be on a GNU platform
# if apt-cache was found. Using unicode reserved range in `fish/tr` and the
# little-endian bytecode equivalent in `sed`. Supports localization.)
apt-cache --no-generate show '.*'(commandline -ct)'.*' 2>/dev/null | sed -r '/^(Package|Description-[a-z]{2}):/!d;s/Package: (.*)/\1\t/g;s/Description-.*: (.*)/\1\xee\x80\x80\x0a/g' | tr -d \n | tr -s \uE000 \n | uniq
apt-cache --no-generate show '.*'(commandline -ct)'.*' 2>/dev/null | sed -r '/^(Package|Description-?[a-z]{0,2}):/!d;s/Package: (.*)/\1\t/g;s/Description-?[^:]*: (.*)/\1\xee\x80\x80\x0a/g' | tr -d \n | tr -s \uE000 \n | uniq
return
else
set -l packages (dpkg --get-selections | string replace -fr '(\S+)\s+install' "\$1" | string match -e (commandline -ct))
apt-cache --no-generate show $packages 2>/dev/null | sed -r '/^(Package|Description-[a-z]{2}):/!d;s/Package: (.*)/\1\t/g;s/Description-.*: (.*)/\1\xee\x80\x80\x0a/g' | tr -d \n | tr -s \uE000 \n | uniq
apt-cache --no-generate show $packages 2>/dev/null | sed -r '/^(Package|Description-?[a-z]{0,2}):/!d;s/Package: (.*)/\1\t/g;s/Description-?[^:]*: (.*)/\1\xee\x80\x80\x0a/g' | tr -d \n | tr -s \uE000 \n | uniq
return
end