Improve Arch Linux package completions

Add completions for `downgrade` tool
Add new `--installed` option for printing Arch packages
Change Arch Linux package related completions to use `--installed`

add newline
This commit is contained in:
Jason Nader 2020-03-14 23:11:33 +09:00 committed by Fabian Homborg
parent 0f681190ba
commit 266ce7c940
5 changed files with 21 additions and 14 deletions

View File

@ -0,0 +1,3 @@
# Arch Linux package downgrader tool
complete -c downgrade -f
complete -c downgrade -xa "(__fish_print_packages --installed)"

View File

@ -1,7 +1,7 @@
set -l progname pacaur
complete -c $progname -f
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
set -l listinstalled "(__fish_print_packages --installed)"
# This might be an issue if another package manager is also installed (e.g. for containers)
set -l listall "(__fish_print_packages)"
set -l listrepos "(__fish_print_pacman_repos)"

View File

@ -4,7 +4,7 @@
set -l progname pacman
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
set -l listinstalled "(__fish_print_packages --installed)"
# This might be an issue if another package manager is also installed (e.g. for containers)
set -l listall "(__fish_print_packages)"
set -l listrepos "(__fish_print_pacman_repos)"

View File

@ -1,7 +1,7 @@
set -l progname yaourt
complete -c $progname -f
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
set -l listinstalled "(__fish_print_packages --installed)"
# This might be an issue if another package manager is also installed (e.g. for containers)
set -l listall "(__fish_print_packages)"
set -l listrepos "(__fish_print_pacman_repos)"

View File

@ -60,19 +60,23 @@ function __fish_print_packages
# Caches for 5 minutes
if type -q -f pacman
set cache_file $XDG_CACHE_HOME/.pac-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
if not set -q only_installed
set cache_file $XDG_CACHE_HOME/.pac-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
# prints: <package name> Package
pacman -Ssq | sed -e 's/$/\t'Package'/' >$cache_file &
return
else
pacman -Q | string replace ' ' \t
return
end
# prints: <package name> Package
pacman -Ssq | sed -e 's/$/\t'Package'/' >$cache_file &
return
end
# Zypper needs caching as it is slow