Show alias value #820
Replies: 1 comment
-
I upgraded zsh-autocomplete for the first time in a couple years--along with a bunch of other configs--and started noticing the
I was reading the zsh docs and it says:
If you use the zsh-users/zsh-completions plugin, like me, it may set that style for you. It will be overridden for the This appears to have been taken from the paragraph in the zsh docs right above the one I quoted. So, I overrode that context in my own config: # .zshrc, after sourcing zsh-autocomplete
zstyle ':completion:*:-command-:*' group-name '' Now, both groups have entries and they're in the correct order (defined by my
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In #532 some folks (@akainth015 and @slacksystem) asked for a feature to list the expansion of the current alias together with the other completions. Here it is in two lines for your zshrc:
How it works
Completion stops when a completer returns success. So, we just have our
_expand_alias
wrapper return failure in all cases.The
zstyle
configuration is just that of zsh-autocomplete with our_expand_alias_and_continue
added.As an example, the completion listing when I type
gs
using the https://github.com/davidde/git plugin now roughly looks likeWhen my cursor is just on
ls --help
, it shows the global coloring--help
alias I configured likeWhat I tried before
The
_alternative
utility function (described inman zshcompsys
) provides three features: forming unions and tagging and describing things. We only use the former, so the function_expand_alias_and_complete() { _alternative ::_expand_alias ::_complete }
forms the union of
_expand_alias
and_complete
.(TheWrong: It messes up with the descriptions already provided.::
in the_alternative
arguments are for<tag>:<description>:
, but as both a tag and a description get provided by_expand_alias
respectively_complete
anyway, we may keep them empty.)The configuration
zstyle ':completion:*' completer _expand_alias_and_complete _ignored
says to use our own function in place of
_complete
in every completion context.The
:completion:*
stands for every completion context. This is necessary for global aliases to work. If you only want the alias to be shown, when in command position use:completion:*::::
which says: we are in no context yet, that is at the beginning of the command line, although we may use some widget (the*
), e.g. for listing the completions as zsh-autocomplete does, when the completions fill the entire screen.What others tried before
The naïve
zstyle ':completion:*' completer _expand_alias _complete _ignored
does not solve this, as it stops as soon as one of the three completers provides a result. So it either shows an alias expansion or normal completions or ignored completions.
What I tried before
Up to now, I solved this for my own by adding a line
in zsh-autocomplete’s
Completions/_autocomplete__command
which simply adds the alias expansion to the list of command completions. This could be made configurable viazstyle ':autocomplete:*' expand-alias on
by adding an extra condition:While this works, it looks somewhat hacky to place the expansion among all the other completions.
Beta Was this translation helpful? Give feedback.
All reactions