diff --git a/share/completions/flatpak.fish b/share/completions/flatpak.fish index 614f418f7..688a80055 100644 --- a/share/completions/flatpak.fish +++ b/share/completions/flatpak.fish @@ -70,6 +70,7 @@ function __fish_print_flatpak_packages return end end + __fish_cache_put $cache_file __fish_flatpak remote-ls --columns=application,name >$cache_file & return 0 end diff --git a/share/functions/__fish_cache_put.fish b/share/functions/__fish_cache_put.fish new file mode 100644 index 000000000..a9162e909 --- /dev/null +++ b/share/functions/__fish_cache_put.fish @@ -0,0 +1,10 @@ +function __fish_cache_put + set -l cache_file $argv[1] + touch $cache_file + set -l dir (path dirname $cache_file) + chown --reference=$dir $cache_file 2>/dev/null || + chown ( + stat --format '%u:%g' $dir 2>/dev/null || + stat -f '%u:%g' $dir + ) $cache_file +end diff --git a/share/functions/__fish_cache_sourced_completions.fish b/share/functions/__fish_cache_sourced_completions.fish index e549fd8cf..333e48f47 100644 --- a/share/functions/__fish_cache_sourced_completions.fish +++ b/share/functions/__fish_cache_sourced_completions.fish @@ -31,9 +31,11 @@ function __fish_cache_sourced_completions # # That means we'll rerun if the command was up- or downgraded. if path is -vrf -- $stampfile $compfile || test "$cmtime" -ne "$mtime" 2>/dev/null + __fish_cache_put $compfile $argv >$compfile # If the command exited unsuccessfully, we assume it didn't work. or return 2 + __fish_cache_put $stampfile echo -- $mtime >$stampfile end diff --git a/share/functions/__fish_print_eopkg_packages.fish b/share/functions/__fish_print_eopkg_packages.fish index 216232e6e..d303ece8e 100644 --- a/share/functions/__fish_print_eopkg_packages.fish +++ b/share/functions/__fish_print_eopkg_packages.fish @@ -21,6 +21,7 @@ function __fish_print_eopkg_packages end end + __fish_cache_put $cache_file # Remove package version information from output and pipe into cache file eopkg list-installed -N | cut -d ' ' -f 1 >$cache_file & return 0 @@ -35,6 +36,7 @@ function __fish_print_eopkg_packages end end + __fish_cache_put $cache_file # Remove package version information from output and pipe into cache file eopkg list-available -N | cut -d ' ' -f 1 >$cache_file & return 0 diff --git a/share/functions/__fish_print_pacman_packages.fish b/share/functions/__fish_print_pacman_packages.fish index 8ff91bb01..242dc496a 100644 --- a/share/functions/__fish_print_pacman_packages.fish +++ b/share/functions/__fish_print_pacman_packages.fish @@ -18,6 +18,7 @@ function __fish_print_pacman_packages return end end + __fish_cache_put $cache_file # prints: Package pacman -Ssq | sed -e 's/$/\t'Package'/' >$cache_file & return 0 diff --git a/share/functions/__fish_print_port_packages.fish b/share/functions/__fish_print_port_packages.fish index 843829496..eb2cb42cb 100644 --- a/share/functions/__fish_print_port_packages.fish +++ b/share/functions/__fish_print_port_packages.fish @@ -15,6 +15,7 @@ function __fish_print_port_packages end end + __fish_cache_put $cache_file # Remove trailing whitespace and pipe into cache file printf "all\ncurrent\nactive\ninactive\ninstalled\nuninstalled\noutdated" >$cache_file port echo all | awk '{$1=$1};1' >>$cache_file & diff --git a/share/functions/__fish_print_rpm_packages.fish b/share/functions/__fish_print_rpm_packages.fish index 051a6eaf6..5f343a2a1 100644 --- a/share/functions/__fish_print_rpm_packages.fish +++ b/share/functions/__fish_print_rpm_packages.fish @@ -20,6 +20,7 @@ function __fish_print_rpm_packages end end + __fish_cache_put $cache_file # Remove package version information from output and pipe into cache file /usr/share/yum-cli/completion-helper.py list all -d 0 -C | sed "s/\..*/\tPackage/" >$cache_file & return @@ -40,6 +41,7 @@ function __fish_print_rpm_packages end # Remove package version information from output and pipe into cache file + __fish_cache_put $cache_file rpm -qa | sed -e 's/-[^-]*-[^-]*$/\t'Package'/' >$cache_file & return end diff --git a/share/functions/__fish_print_xbps_packages.fish b/share/functions/__fish_print_xbps_packages.fish index af113439e..7a3bd9b1e 100644 --- a/share/functions/__fish_print_xbps_packages.fish +++ b/share/functions/__fish_print_xbps_packages.fish @@ -18,6 +18,7 @@ function __fish_print_xbps_packages return end end + __fish_cache_put $cache_file # prints: Package xbps-query -Rs "" | sed 's/^... \([^ ]*\)-.* .*/\1/; s/$/\t'Package'/' | tee $cache_file return 0