mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 06:05:39 +08:00
Improve eopkg completions by using the --installed
flag (#5089)
Utilized the `--install` flag added in commit #8c09d6e. Limit `eopkg remove/autoremove/check ...` completions to installed packages. Limit `eopkg install/upgrade/info ...` completions to available packages.
This commit is contained in:
parent
6a6ffe68cb
commit
e26bdff487
|
@ -163,6 +163,7 @@ Xcode builds and macOS packages could not be produced with 2.7b1, but this is fi
|
|||
- `apt`
|
||||
- `cd` (#4061)
|
||||
- `composer` (#4295)
|
||||
- `eopkg`
|
||||
- `flatpak` (#4456)
|
||||
- `git` (#4117, #4147, #4329, #4368)
|
||||
- `gphoto2`
|
||||
|
|
|
@ -39,7 +39,8 @@ end
|
|||
|
||||
# Setup additional completion
|
||||
complete -f -c eopkg -n '__fish_seen_subcommand_from remove-repo rr enable-repo er disable-repo dr list-available la' -a "(__fish_eopkg_print_repos)" -d "Repository"
|
||||
complete -f -c eopkg -n '__fish_seen_subcommand_from upgrade up remove rm autoremove rmf install it info check' -a "(__fish_print_packages)" -d "Package"
|
||||
complete -f -c eopkg -n '__fish_seen_subcommand_from upgrade up install it info' -a "(__fish_print_packages)" -d "Available Package"
|
||||
complete -f -c eopkg -n '__fish_seen_subcommand_from remove rm autoremove rmf check' -a "(__fish_print_packages --installed)" -d "Installed Package"
|
||||
complete -f -c eopkg -n '__fish_seen_subcommand_from upgrade up remove rm install it info check list-available la list-installed li list-upgrades lu' -s c -l component -a "(__fish_eopkg_print_components)" -d "Component"
|
||||
|
||||
# Setup eopkg subcommand with shortcut
|
||||
|
|
|
@ -145,20 +145,37 @@ function __fish_print_packages
|
|||
if type -q -f eopkg
|
||||
|
||||
# If the cache is less than max_age, we do not recalculate it
|
||||
# Determine whether to print installed/available packages
|
||||
|
||||
set cache_file $XDG_CACHE_HOME/.eopkg-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 500
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
if set -q only_installed
|
||||
set cache_file $XDG_CACHE_HOME/.eopkg-installed-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 500
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Remove package version information from output and pipe into cache file
|
||||
eopkg list-available -N | cut -d ' ' -f 1 >$cache_file &
|
||||
return
|
||||
# Remove package version information from output and pipe into cache file
|
||||
eopkg list-installed -N | cut -d ' ' -f 1 >$cache_file &
|
||||
return
|
||||
else
|
||||
set cache_file $XDG_CACHE_HOME/.eopkg-available-cache.$USER
|
||||
if test -f $cache_file
|
||||
cat $cache_file
|
||||
set age (math (date +%s) - (stat -c '%Y' $cache_file))
|
||||
set max_age 500
|
||||
if test $age -lt $max_age
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
# Remove package version information from output and pipe into cache file
|
||||
eopkg list-available -N | cut -d ' ' -f 1 >$cache_file &
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
# This completes the package name from the portage tree.
|
||||
|
|
Loading…
Reference in New Issue
Block a user