mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
parent
59da180b8f
commit
a6a41d159c
1 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue