Introduce __fish_print_pacman_repos helper

This is used in at least 4 places, all of which have a bug in that they
print "options" as a valid repo. It seems better to fix it once,
especially given that there are tons of AUR helpers and pacman wrappers,
all of which might need this info.
This commit is contained in:
Fabian Homborg 2015-09-25 13:22:09 +02:00
parent 8abb19aaca
commit d591cebf44
5 changed files with 7 additions and 4 deletions

View file

@ -10,7 +10,7 @@ complete -c cower -f -s f -l 'force' -d 'Overwrite existing files whe
complete -c cower -f -l 'format' -d 'Print formatted'
complete -c cower -f -s h -l 'help' -d 'Display help and quit'
complete -c cower -f -l 'ignore' -xa "(pacman -Qq)" -d 'Ignore a package upgrade'
complete -c cower -f -l 'ignorerepo' -xa "(cat /etc/pacman.conf | grep '^\[.\+\]' | sed 's/[]\[]//g')" -d 'Ignore a binary repo when checking for updates'
complete -c cower -f -l 'ignorerepo' -xa "(__fish_print_pacman_repos)" -d 'Ignore a binary repo when checking for updates'
complete -c cower -f -l 'listdelim' -d 'Specify a delimiter for list formatters'
complete -c cower -f -s q -l 'quiet' -d 'Output less'
complete -c cower -f -s t -l 'target' -d 'Download targets to DIR'

View file

@ -2,7 +2,7 @@
set -l listinstalled "(pacman -Qm | tr ' ' \t)"
set -l listall "(pacman -Sl | cut --delim ' ' --fields 2- | tr ' ' \t)"
set -l listrepos "(cat /etc/pacman.conf | grep '^\[.\+\]' | sed 's/[]\[]//g')"
set -l listrepos "(__fish_print_pacman_repos)"
set -l listgroups "(pacman -Sg | sed 's/\(.*\)/\1\tPackage group/g')"

View file

@ -7,7 +7,7 @@ set -l progname pacman
set -l listinstalled "(pacman -Q | tr ' ' \t)"
# 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 "(grep '^\[.\+\]' /etc/pacman.conf | sed 's/[]\[]//g')"
set -l listrepos "(__fish_print_pacman_repos)"
set -l listgroups "(pacman -Sg | sed 's/\(.*\)/\1\tPackage group/g')"
set -l noopt 'not __fish_contains_opt -s S -s D -s Q -s R -s U -s T database query sync remove upgrade deptest'

View file

@ -4,7 +4,7 @@ complete -c pkgfile -s b -l binaries -d 'only show files in a {s}bin/ director
complete -c pkgfile -s c -l case-sensitive -d 'make searches case sensitive'
complete -c pkgfile -s g -l glob -d 'allow the use of * and ? as wildcards'
complete -c pkgfile -s r -l regex -d 'allow the use of regex in searches'
complete -c pkgfile -s R -l repo -d 'search only in the specified repository' -xa '(cat /etc/pacman.conf|grep "^\[" | sed "s/\[\|]//g")'
complete -c pkgfile -s R -l repo -d 'search only in the specified repository' -xa '(__fish_print_pacman_repos)'
complete -c pkgfile -s v -l verbose -d 'enable verbose output'
complete -c pkgfile -s i -l info -d 'provides information about the package owning a file' -r
complete -c pkgfile -s l -l list -d 'list files of a given package; similar to "pacman -Ql"' -xa "(pacman -Sl | cut --delim ' ' --fields 2- | tr ' ' \t | sort)"

View file

@ -0,0 +1,3 @@
function __fish_print_pacman_repos --description "Print the repositories configured for arch's pacman package manager"
sed -n -e 's/\[\(.\+\)\]/\1/p' /etc/pacman.conf | grep -v "#\|options"
end