mirror of
https://github.com/Jguer/yay.git
synced 2025-11-28 00:05:15 -05: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
|
// Complete provides completion info for shells
|
||||||
func Complete() (err error) {
|
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 {
|
if info, err := os.Stat(path); os.IsNotExist(err) || time.Since(info.ModTime()).Hours() > 48 {
|
||||||
os.MkdirAll(os.Getenv("HOME")+"/.cache/yay", 0755)
|
os.MkdirAll(os.Getenv("HOME")+"/.cache/yay", 0755)
|
||||||
|
|||||||
@ -90,8 +90,8 @@ _yay() {
|
|||||||
_pacman_pkg Qq;;
|
_pacman_pkg Qq;;
|
||||||
S)
|
S)
|
||||||
{ _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
|
{ _arch_incomp 'g groups' && _pacman_pkg Sg; } ||
|
||||||
{ _arch_incomp 'l list' && _arch_compgen "$(yay --complete bash | \sort -u)"; } ||
|
{ _arch_incomp 'l list' && _arch_compgen "$(yay --complete | \sort -u)"; } ||
|
||||||
_arch_compgen "$(yay --complete bash)";;
|
_arch_compgen "$(yay --complete )";;
|
||||||
U)
|
U)
|
||||||
_pacman_file;;
|
_pacman_file;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -42,7 +42,7 @@ func parser() (op string, options []string, packages []string, err error) {
|
|||||||
}
|
}
|
||||||
op = "yogurt"
|
op = "yogurt"
|
||||||
|
|
||||||
for i, arg := range os.Args[1:] {
|
for _, arg := range os.Args[1:] {
|
||||||
if arg[0] == '-' && arg[1] != '-' {
|
if arg[0] == '-' && arg[1] != '-' {
|
||||||
switch arg {
|
switch arg {
|
||||||
case "-b":
|
case "-b":
|
||||||
@ -61,10 +61,13 @@ func parser() (op string, options []string, packages []string, err error) {
|
|||||||
util.SortMode = util.BottomUp
|
util.SortMode = util.BottomUp
|
||||||
case "--topdown":
|
case "--topdown":
|
||||||
util.SortMode = util.TopDown
|
util.SortMode = util.TopDown
|
||||||
|
|
||||||
case "--complete":
|
case "--complete":
|
||||||
if len(os.Args) > i+3 {
|
util.Shell = "sh"
|
||||||
util.Shell = os.Args[i+2]
|
yay.Complete()
|
||||||
}
|
os.Exit(0)
|
||||||
|
case "--fcomplete":
|
||||||
|
util.Shell = "fish"
|
||||||
yay.Complete()
|
yay.Complete()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
case "--help":
|
case "--help":
|
||||||
|
|||||||
2
yay.fish
2
yay.fish
@ -5,7 +5,7 @@ set -l progname yay
|
|||||||
|
|
||||||
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
|
set -l listinstalled "(pacman -Q | string replace ' ' \t)"
|
||||||
# This might be an issue if another package manager is also installed (e.g. for containers)
|
# 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 listrepos "(__fish_print_pacman_repos)"
|
||||||
set -l listgroups "(pacman -Sg)\t'Package Group'"
|
set -l listgroups "(pacman -Sg)\t'Package Group'"
|
||||||
set -l listpacman "(__fish_print_packages)"
|
set -l listpacman "(__fish_print_packages)"
|
||||||
|
|||||||
@ -308,11 +308,11 @@ _pacman_completions_all_packages() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if compset -P1 '*/*'; then
|
if compset -P1 '*/*'; then
|
||||||
packages=( $(_call_program packages yay --complete zsh ${words[CURRENT]%/*}) )
|
packages=( $(_call_program packages yay --complete ${words[CURRENT]%/*}) )
|
||||||
typeset -U packages
|
typeset -U packages
|
||||||
${seq} _wanted repo_packages expl "repository/package" compadd ${sep[@]} ${(@)packages}
|
${seq} _wanted repo_packages expl "repository/package" compadd ${sep[@]} ${(@)packages}
|
||||||
else
|
else
|
||||||
packages=( $(_call_program packages yay --complete zsh) )
|
packages=( $(_call_program packages yay --complete ) )
|
||||||
typeset -U packages
|
typeset -U packages
|
||||||
${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"
|
${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user