From: Paul Seyfert <pseyfert@mathphys.fsk.uni-heidelberg.de>
To: zsh-users@zsh.org
Subject: [solved] Re: _gnu_generic for aliases
Date: Thu, 2 Jun 2016 12:20:50 +0200 [thread overview]
Message-ID: <57500882.6090900@mathphys.fsk.uni-heidelberg.de> (raw)
In-Reply-To: <160601223030.ZM14495@torch.brasslantern.com>
[-- Attachment #1: Type: text/plain, Size: 2448 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
On 02.06.2016 07:30, Bart Schaefer wrote:
> On May 19, 10:50am, Paul Seyfert wrote:
> }
> } I crosschecked that also
> }
> } compdef _gnu_generic fancyalias
> }
> } does not result in any suggestions. My understanding is that the
> } _gnu_generic function does not know about the fancyalias / I cannot use
> } the fancyalias inside the _gnu_generic function.
> }
> } Is there a way to make _gnu_generic work for aliases?
>
> Have you tried "setopt complete_aliases" ?
Yes,
I created a small test setup attached:
put "testme.sh" in /tmp/ start zsh with
NORMALPROMPT > zsh -f
defaultprompt > source testrc
defaultprompt > /tmp/testme.sh -<TAB><TAB>
works fine
defaultprompt > fancy -<TAB><TAB><TAB>
nothing.
> Unfortunately it's not easily possible to have it both ways, that is, to
> treat an alias as something you can "compdef" and ALSO have the alias be
> expanded to use the completion for the command it eventually becomes.
>
> This might work a lot of the time:
>
> setopt complete_aliases
> _expand_alias_and_complete() {
> if [[ -o complete_aliases && -n $aliases[$words[1]] ]]; then
> words[1]=( $aliases[$words[1]] )
> _complete
> else
> return 1
> fi
> }
> zstyle ':completion:*' completer _complete __expand_alias_and_complete
I have that block commented out in testrc. Once I include it, it works!
>
> Needs tweaking based on the rest of your current "completer" style, but
> hopefully you get the idea.
>
So far it seems to work as-is when enabeling all other completion
settings (I didn't put all in testrc).
Thanks!
Paul
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iQIcBAEBCAAGBQJXUAiCAAoJEPOmP9OjPXmroU8P/20/9V+MZVTYUzEfN8V+G/rG
4XyFcWKVSUTlKV2dnSjnUzk4W1+9nOLphakU5ytd8vcDjg9iyNYi7gQ1tombg+2q
kKtgizmdW08wn4IroDDdO2CQ2tx5C87y9GSw5/QI9YS/b9+0W2R8APTpHthuj4si
UwOSIXkGkIrYVSYBcYZjrW4LJarO6gDyUVZg4XKEunjLwLYbKALDGSKdBc8ewUcI
wiYeXiYGyn79wa+VjzGCOG80/uA9TJKjJG6pCbMvDyMVUH/DoUoWR4GKBWivOz3s
I6HHUcL4E8JHKucbckobiBNPxkx6Ei7c2o/hrT1kWPJrv3VQXnqfe6/yzgJzyjhM
zVFhAyZkqxPUV7cB4WXrMi6jHR7ZXB61PVnp6IncIAYxU1qvQiumy9tpDe8sdc8U
y0hSFzqbeI3fdabZvjX3Zmww91iBB8Iyhg7TCEKA7Dkgr04whAAcJvOeXsesLYf4
tHigU8g7VZWOBMV7TnxxJKxCiPTEd+uAv7OHJ7qUIjxDh1lX0+DbOfxY0dP5O9Xc
mz2/YbJzf13bKMw0RHXMwuI8uUGofNXDvBZy9Zr2ayPzBMXMmGRwV4paBPXdWrGw
1PC7eNad1Tm+cwpixRNU+2O5KW3EpOBAG57WSOQLpg2Td3DwBCAb/EJ40GA8soY7
+zFlbtfuZBNX8ULtRQk5
=d2KE
-----END PGP SIGNATURE-----
[-- Attachment #2: testme.sh --]
[-- Type: application/x-shellscript, Size: 314 bytes --]
[-- Attachment #3: testrc --]
[-- Type: text/plain, Size: 977 bytes --]
autoload -U compinit
compinit
setopt +o bashautolist
setopt +o listambiguous
setopt +o autolist
zstyle ':completion:*:default' menu select=0
zstyle ':completion:*:default' compstate last_prompt=1
alias "fancy"=". /tmp/testme.sh"
setopt complete_aliases
compdef _gnu_generic testme.sh
compdef _gnu_generic fancy
# Messages/warnings format
zstyle ':completion:*:descriptions' format $'%{\e[0;33m%}%d:%{\e[0m%}'
zstyle ':completion:*:messages' format $'%{\e[0;31m%}%d%{\e[0m%}'
zstyle ':completion:*:warnings' format $'%{\e[0;31m%}No matches for: %d%{\e[0m%}'
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
#setopt complete_aliases
#_expand_alias_and_complete() {
# if [[ -o complete_aliases && -n $aliases[$words[1]] ]]; then
# words[1]=( $aliases[$words[1]] )
# _complete
# else
# return 1
# fi
#}
#zstyle ':completion:*' completer _complete _expand_alias_and_complete
setopt NO_BEEP
next prev parent reply other threads:[~2016-06-02 11:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-19 8:50 Paul Seyfert
2016-06-02 5:30 ` Bart Schaefer
2016-06-02 10:20 ` Paul Seyfert [this message]
2016-06-03 8:05 ` [solved] " Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57500882.6090900@mathphys.fsk.uni-heidelberg.de \
--to=pseyfert@mathphys.fsk.uni-heidelberg.de \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).