mirror of
https://github.com/Jguer/yay
synced 2024-07-22 18:56:44 +00:00
Bruteforce fish completions into submission.
This commit is contained in:
parent
47a061315e
commit
4abdb4956f
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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":
|
||||
|
|
2
yay.fish
2
yay.fish
|
@ -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)"
|
||||
|
|
|
@ -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}"
|
||||
|
||||
|
|
Loading…
Reference in a new issue