diff --git a/actions.go b/actions.go index ae402394..3aaede0c 100644 --- a/actions.go +++ b/actions.go @@ -339,10 +339,13 @@ func Complete() (err error) { if err != nil { return err } - defer out.Close() - aur.CreateAURList(out) + if aur.CreateAURList(out) != nil { + defer os.Remove(path) + } err = pac.CreatePackageList(out) + + out.Close() return err } diff --git a/bash-completion b/bash-completion index 84be8e46..03a3bcc2 100644 --- a/bash-completion +++ b/bash-completion @@ -50,7 +50,7 @@ _pacman_pkg() { )" } -_pacman() { +_yay() { local common core cur database prev query remove sync upgrade o COMPREPLY=() _get_comp_words_by_ref cur prev @@ -90,7 +90,7 @@ _pacman() { _pacman_pkg Qq;; S) { _arch_incomp 'g groups' && _pacman_pkg Sg; } || - { _arch_incomp 'l list' && _pacman_pkg Sl sort; } || + { _arch_incomp 'l list' && $(yay --complete bash); } || _pacman_pkg Slq;; U) _pacman_file;; @@ -103,6 +103,6 @@ _pacman_file() { compopt -o filenames; _filedir 'pkg.tar*' } -complete -F _pacman -o default yay +complete -F _yay -o default yay # ex:et ts=2 sw=2 ft=sh diff --git a/cmd/yay/yay.go b/cmd/yay/yay.go index 1ad7a3c0..4d51d70d 100644 --- a/cmd/yay/yay.go +++ b/cmd/yay/yay.go @@ -63,6 +63,8 @@ func parser() (op string, options []string, packages []string, err error) { util.SortMode = util.TopDown case "--complete": util.Shell = os.Args[i+1] + fmt.Println(util.Shell) + os.Exit(0) yay.Complete() os.Exit(0) case "--help":