Bruteforce fish completions into submission.

This commit is contained in:
Jguer 2017-04-10 01:38:58 +01:00
parent 47a061315e
commit 4abdb4956f
5 changed files with 13 additions and 10 deletions

View file

@ -330,7 +330,7 @@ func GetPkgbuild(pkg string) (err error) {
// Complete provides completion info for shells
func Complete() (err error) {
path := os.Getenv("HOME") + "/.cache/yay/aur.cache"
path := os.Getenv("HOME") + "/.cache/yay/aur_" + util.Shell + ".cache"
if info, err := os.Stat(path); os.IsNotExist(err) || time.Since(info.ModTime()).Hours() > 48 {
os.MkdirAll(os.Getenv("HOME")+"/.cache/yay", 0755)

View file

@ -90,8 +90,8 @@ _yay() {
_pacman_pkg Qq;;
S)
{ _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
{ _arch_incomp 'l list' && _arch_compgen "$(yay --complete bash | \sort -u)"; } ||
_arch_compgen "$(yay --complete bash)";;
{ _arch_incomp 'l list' && _arch_compgen "$(yay --complete | \sort -u)"; } ||
_arch_compgen "$(yay --complete )";;
U)
_pacman_file;;
esac

View file

@ -42,7 +42,7 @@ func parser() (op string, options []string, packages []string, err error) {
}
op = "yogurt"
for i, arg := range os.Args[1:] {
for _, arg := range os.Args[1:] {
if arg[0] == '-' && arg[1] != '-' {
switch arg {
case "-b":
@ -61,10 +61,13 @@ func parser() (op string, options []string, packages []string, err error) {
util.SortMode = util.BottomUp
case "--topdown":
util.SortMode = util.TopDown
case "--complete":
if len(os.Args) > i+3 {
util.Shell = os.Args[i+2]
}
util.Shell = "sh"
yay.Complete()
os.Exit(0)
case "--fcomplete":
util.Shell = "fish"
yay.Complete()
os.Exit(0)
case "--help":

View file

@ -5,7 +5,7 @@ set -l progname yay
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
# This might be an issue if another package manager is also installed (e.g. for containers)
set -l listall "(yay --complete fish)"
set -l listall "(yay --fcomplete)"
set -l listrepos "(__fish_print_pacman_repos)"
set -l listgroups "(pacman -Sg)\t'Package Group'"
set -l listpacman "(__fish_print_packages)"

View file

@ -308,11 +308,11 @@ _pacman_completions_all_packages() {
fi
if compset -P1 '*/*'; then
packages=( $(_call_program packages yay --complete zsh ${words[CURRENT]%/*}) )
packages=( $(_call_program packages yay --complete ${words[CURRENT]%/*}) )
typeset -U packages
${seq} _wanted repo_packages expl "repository/package" compadd ${sep[@]} ${(@)packages}
else
packages=( $(_call_program packages yay --complete zsh) )
packages=( $(_call_program packages yay --complete ) )
typeset -U packages
${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"