From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13271 invoked by alias); 2 Jun 2016 11:09:31 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21604 Received: (qmail 18350 invoked from network); 2 Jun 2016 11:09:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 Subject: [solved] Re: _gnu_generic for aliases To: zsh-users@zsh.org References: <573D7E67.10600@mathphys.fsk.uni-heidelberg.de> <160601223030.ZM14495@torch.brasslantern.com> From: Paul Seyfert X-Enigmail-Draft-Status: N1210 Message-ID: <57500882.6090900@mathphys.fsk.uni-heidelberg.de> Date: Thu, 2 Jun 2016 12:20:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0 MIME-Version: 1.0 In-Reply-To: <160601223030.ZM14495@torch.brasslantern.com> Content-Type: multipart/mixed; boundary="------------030106050506040004010905" --------------030106050506040004010905 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit -----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 - works fine defaultprompt > fancy - 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----- --------------030106050506040004010905 Content-Type: application/x-shellscript; name="testme.sh" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="testme.sh" IyEvYmluL3pzaAoKY2FzZSAkMSBpbiAKICAtLWhlbHApCiAgICBlY2hvICIgLS1hICAgcHJp bnQgYW4gJ2EnIgogICAgZWNobyAiIC0tYiAgIHByaW50IGEgICdiJyIKICAgIGVjaG8gIiAt LWMgICBwcmludCBhbGwgdm93ZWxzIgogICAgcmV0dXJuIDAKICAgIDs7CiAgLS1hKQogICAg ZWNobyAiYSIKICAgIHJldHVybiAwCiAgICA7OwogIC0tYikKICAgIGVjaG8gImIiCiAgICBy ZXR1cm4gMAogICAgOzsKICAtLWMpCiAgICBlY2hvICJhZWlvdSIKICAgIHJldHVybiAwCiAg ICA7OwogICopCiAgICByZXR1cm4gMQogICAgOzsKZXNhYwpyZXR1cm4gMAo= --------------030106050506040004010905 Content-Type: text/plain; charset=UTF-8; name="testrc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="testrc" autoload -U compinit compinit setopt +o bashautolist setopt +o listambiguous setopt +o autolist zstyle ':completion:*:default' menu select=3D0 zstyle ':completion:*:default' compstate last_prompt=3D1 alias "fancy"=3D". /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]=3D( $aliases[$words[1]] ) # _complete # else # return 1 # fi #} #zstyle ':completion:*' completer _complete _expand_alias_and_complete setopt NO_BEEP --------------030106050506040004010905--