__fish_print_packages: add support for zypper

Closes #1787.
This commit is contained in:
David Adam 2014-11-13 18:15:35 +08:00
parent 59da180b8f
commit a6a41d159c

View file

@ -52,6 +52,25 @@ function __fish_print_packages
return
end
# Zypper needs caching as it is slow
if type -q -f zypper
# If the cache is less than five minutes old, we do not recalculate it
set -l cache_file $XDG_CACHE_HOME/.zypper-cache.$USER
if test -f $cache_file
cat $cache_file
set -l age (math (date +%s) - (stat -c '%Y' $cache_file))
set -l max_age 300
if test $age -lt $max_age
return
end
end
# Remove package version information from output and pipe into cache file
zypper --quiet --non-interactive search --type=package | tail -n +4 | sed -E 's/^. \| ((\w|[-_.])+).*/\1\t'$package'/g' > $cache_file &
return
end
# yum is slow, just like rpm, so go to the background
if type -q -f /usr/share/yum-cli/completion-helper.py