diff options
author | 2013-03-01 23:27:03 +0330 | |
---|---|---|
committer | 2013-03-01 23:27:03 +0330 | |
commit | 87aca05e7f254a65e22d49293e1ce6893af9a5e2 (patch) | |
tree | 79fb7f05c3cd7f7f56a837bdda75ed7265cabdeb /share/functions/__fish_print_packages.fish | |
parent | 94b1d58cc28800cbc7f00febf499a1d9c9928a21 (diff) |
autocomplete 'yum install' using yum cache
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 1991bd6d..6573ce8e 100644 --- a/share/functions/__fish_print_packages.fish +++ b/share/functions/__fish_print_packages.fish @@ -22,6 +22,25 @@ function __fish_print_packages return end + # yum is slow, just like rpm, so go to the background + if type -f /usr/share/yum-cli/completion-helper.py >/dev/null + + # If the cache is less than five minutes old, we do not recalculate it + + set cache_file /tmp/.yum-cache.$USER + if test -f $cache_file + cat $cache_file + set age (math (date +%s) - (stat -c '%Y' $cache_file)) + set max_age 250 + if test $age -lt $max_age + return + end + end + + # Remove package version information from output and pipe into cache file + /usr/share/yum-cli/completion-helper.py list all -d 0 -C >$cache_file | cut -d '.' -f 1 | sed '1d' | sed '/^\s/d' | sed -e 's/$/'\t$package'/' & + end + # Rpm is too slow for this job, so we set it up to do completions # as a background job and cache the results. |