completions/flatpak: don't ignore packages with uppercase in name (#11230)

* completions/flatpak: don't ignore packages with uppercase in name

`[^A-Z]+` here seems to trim header section in old version flatpak (avoid one
more `tail -n -2`?) but this can ignore packages have uppercase name like
`org.gtk.Gtk3theme.Adwaita-dark`.

* completions/flatpak: use cached `__fish_print_flatpak_packages` for `flatpak install`
This commit is contained in:
phanium
2025-03-07 13:39:10 +08:00
committed by GitHub
parent cc455ff976
commit 6e8d6328ee

View File

@@ -55,7 +55,23 @@ function __fish_flatpak
# We can't rely on the first line being the headers because modern flatpak will omit it when running in a "subshell".
# Based off our invocations, we expect the first column of actual output to never contain a capitalized letter
# (unlike the header row).
flatpak $argv | string replace -rf '^([^A-Z]+)(?: +|\t)(.*?)\s*$' '$1\t$2'
flatpak $argv | string replace -rf '^([^A-Z].*?)(?: +|\t)(.*?)\s*$' '$1\t$2'
end
function __fish_print_flatpak_packages
set -l xdg_cache_home (__fish_make_cache_dir)
or return
set -l cache_file $xdg_cache_home/flatpak
if test -f $cache_file
cat $cache_file
set -l age (path mtime -R -- $cache_file)
set -l max_age 250
if test $age -lt $max_age
return
end
end
__fish_flatpak remote-ls --columns=application,name >$cache_file &
return 0
end
complete -f -c flatpak -n "__fish_seen_subcommand_from run" -a "(__fish_flatpak list --app --columns=application,name)"
@@ -63,7 +79,7 @@ complete -f -c flatpak -n "__fish_seen_subcommand_from info uninstall" -a "(__fi
complete -f -c flatpak -n "__fish_seen_subcommand_from enter kill" -a "(__fish_flatpak ps --columns=instance,application)"
complete -f -c flatpak -n "__fish_seen_subcommand_from remote-info remote-ls remote-modify remote-delete" -a "(__fish_flatpak remotes --columns=name,title)"
complete -c flatpak -n '__fish_seen_subcommand_from install' -xa "(__fish_flatpak remote-ls --columns=application,name)"
complete -c flatpak -n '__fish_seen_subcommand_from install' -xa "(__fish_print_flatpak_packages)"
# Plenty of the other stuff is too free-form to complete (e.g. remote-add).
complete -f -c flatpak -s h -l help