Bash and zsh completions
Let's provide bash and zsh completion definitions. Maybe fish, too?
They're out there in some other packages. Maybe we could pull those in.
### bash
[Fedora's cowsay package](https://packages.fedoraproject.org/pkgs/cowsay/cowsay/) has bash completion definitions, in a source file ([cowsay.bashcomp](https://src.fedoraproject.org/rpms/cowsay/blob/rawhide/f/cowsay.bashcomp)) local to the RPM package spec, licensed under GPL v2. Looks like they were in turn pulled in from Gentoo.
### zsh
_Something_ seems to be supplying zsh completions for cowsay on my Mac. When I do `cowsay -f x<TAB>`, it completes the unqualified cow name from the set of installed cows. Don't know what's supplying that. I have the Homebrew `zsh-completions` package installed, but I don't see cowsay completions there.
I see this in my shell:
```
$ which _cowsay
_cowsay () {
local context state line
typeset -A opt_args
_arguments -s -S -A "-*" "(H mode)-e+[specify cow's eyes]:eye string [oo]" '(H)-f+[specify cowfile]:cowfile:->cowfile' "(H mode)-T+[specify cow's tongue]:tongue string" '(H)-W+[specify width for message word wrap]:wrap column [40]' '(H)-n[no wordwrap]' '*:message' + 'H' '(- *)-h[display usage information]' '(- *)-l[list all cowfiles]' + '(mode)' '(H -e -T)-b[borg mode]' '(H -e -T)-d[dead mode]' '(H -e -T)-g[greedy mode]' '(H -e -T)-p[paranoia mode]' '(H -e -T)-s[stoned mode]' '(H -e -T)-t[tired mode]' '(H -e -T)-w[wired mode]' '(H -e -T)-y[youthful mode]' && return
case "$state" in
(cowfile) _wanted -C option-f-1 cowfiles expl 'cow file' compadd ${=${(f)"$(_call_program cowfiles $words[1] -l)"}:#*\:} || _files -g "*.cow(-.)" ;;
esac
}
$ locate _cowsay
/usr/local/Cellar/zsh/5.9/share/zsh/functions/_cowsay
/usr/local/share/zsh/functions/_cowsay
/usr/share/zsh/5.9/functions/_cowsay
```
Does that mean that _zsh itself_ supplies cowsay completions? Sure looks like it.
We still might want to supply our own zsh completions, to support changes to the `cowsay` interface that have happened since the zsh release.
0 条评论