From d591cebf4463e42569400bbcbaba5e16dcad734b Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 25 Sep 2015 13:22:09 +0200 Subject: [PATCH] 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. --- share/completions/cower.fish | 2 +- share/completions/meat.fish | 2 +- share/completions/pacman.fish | 2 +- share/completions/pkgfile.fish | 2 +- share/functions/__fish_print_pacman_repos.fish | 3 +++ 5 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 share/functions/__fish_print_pacman_repos.fish diff --git a/share/completions/cower.fish b/share/completions/cower.fish index 97817e86f..743b44455 100644 --- a/share/completions/cower.fish +++ b/share/completions/cower.fish @@ -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' diff --git a/share/completions/meat.fish b/share/completions/meat.fish index 8e33c3c34..4af7f7a53 100644 --- a/share/completions/meat.fish +++ b/share/completions/meat.fish @@ -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')" diff --git a/share/completions/pacman.fish b/share/completions/pacman.fish index f96cdcbfc..30453cf60 100644 --- a/share/completions/pacman.fish +++ b/share/completions/pacman.fish @@ -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' diff --git a/share/completions/pkgfile.fish b/share/completions/pkgfile.fish index e8af0b0fa..dae11771a 100644 --- a/share/completions/pkgfile.fish +++ b/share/completions/pkgfile.fish @@ -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)" diff --git a/share/functions/__fish_print_pacman_repos.fish b/share/functions/__fish_print_pacman_repos.fish new file mode 100644 index 000000000..81fe3de5d --- /dev/null +++ b/share/functions/__fish_print_pacman_repos.fish @@ -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