diff options
author | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2014-11-13 18:15:35 +0800 |
---|---|---|
committer | David Adam <zanchey@ucc.gu.uwa.edu.au> | 2014-11-13 18:15:35 +0800 |
commit | a6a41d159cd4e34d5db7db8c6e29629c7db91d15 (patch) | |
tree | 38adc82afd72ce93d4e370fef720fd96c8d180cc /share/functions/__fish_print_packages.fish | |
parent | 59da180b8f06e0a94875d52d2862e83f9272e3b6 (diff) |
__fish_print_packages: add support for zypper
Closes #1787.
Diffstat (limited to 'share/functions/__fish_print_packages.fish')
-rw-r--r-- | share/functions/__fish_print_packages.fish | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/share/functions/__fish_print_packages.fish b/share/functions/__fish_print_packages.fish index 050fcac2..eb8470f4 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -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 |