Repository navigation
Add zsh compdef completion script. - #14239
Conversation
|
IMO, this should replace the existing |
|
@omajid we don't include this script "in the box". So far we only point user to the instruction in Github to manually add it. Btw, have you tried this script? Or could you help review this script? I don't know too much about zsh, so it takes a while for me to look into it. |
|
@sfoslund how much auto completion of system commandline is "online" in SDK? |
It should be enabled for all commands, I recently fixed a "dotnet add package" specific issue but otherwise it has been supported since the original PR. |
|
with some configure, the library should support |
|
The CLI supports the |
No, sorry, I dont use zsh so I haven't reviewed or test it :( |
Interesting. Is that true for bash completion too? For the Fedora .NET Core 3.1 package, we can install/use it in from the source repo: https://src.fedoraproject.org/rpms/dotnet3.1/blob/7d66170eeba7d2f13cd15d1c05d1c259ba48c324/f/dotnet3.1.spec#_481 |
|
@omajid it is the same for bash. It is something to be put in user's bashrc. We need an explicit agreement from the user. We need to design a UX for that, which is not trivial |
If you are installing the SDK system wide, why not put the bash completion system-wide too? And if the user agrees with installing the software in the system, why wouldn't they agree with the auto-completion? If there are privacy implications, then I guess that would explain why the need for explicit agreement and UX design. |
|
My understanding is bashrc belongs to the user. No program should directly edit it. Also, simply append more lines to it will not always work. |
That's right. You shouldn't edit the user's bashrc. But you can add system-wide completion by dropping completion files into the system-wide completion directory. That's what it's meant for. That's where programs like From the FAQ:
|
|
That's a good news. Is |
Probably not. The bash completion FAQ I linked above says that I think this location is for bash only. I dont know enough about zsh to figure out where that lies. Google says the environment variables |
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
FYI I'm still looking at this issue from time to time and I'm still a noob when it comes to zsh stuff. If there's anybody you know that's more knowledgeable in these things and would like to take a look that would be great, I don't believe it should be a big problem because package maintainers include their completions for all kinds of stuff |
|
ultimately I think that the zsh completion scripts should land in (thanks Megame50) |
I am a package maintainer in Fedora and I would love to include zsh shell completions for dotnet too! Currently we only include dotnet completions for bash. |
|
Based on some new work on System.CommandLine's completions for #compdef dotnet
# debug lines, uncomment to get state variables passed to this function
# echo "\n\n\nstate:\t'$state'"
# echo "line:\t'$line'"
# echo "words:\t$words"
# Get the full line
# $words array when quoted like this gets expanded out into the full line
full_line="$words"
# Get the completion results, will be newline-delimited
completions=$(dotnet complete "$full_line")
# explode the completions by linefeed instead of by spaces into the descriptions for the
# _values helper function.
exploded=(${(f)completions})
_values 'suggestions' $explodedWhen we add description support to described=()
for i in {1..$#exploded}; do
argument="${exploded[$i]}"
description="hello description $i"
entry=($argument"["$description"]")
described+=("$entry")
doneand the |
|
For what it's worth, at Alpine Linux we''ve been applying the following patch for zsh completion support: From 4c74721e1f5da9642adab03075dda2f55719ac7b Mon Sep 17 00:00:00 2001
Patch-Source: https://github.com/dotnet/sdk/pull/14239
From: Esgariot <[email protected]>
Date: Mon, 19 Oct 2020 23:42:37 +0200
Subject: [PATCH 1/1] Add zsh compdef completion script.
Continuing off of PR 13384 in upstream.
This commit is ready to be rebased to include appropriate co-authors
before merging PR.
---
scripts/register-completions.zsh | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/src/sdk/scripts/register-completions.zsh b/src/sdk/scripts/register-completions.zsh
index 8eebe9a867..faa32fef71 100644
--- a/src/sdk/scripts/register-completions.zsh
+++ b/src/sdk/scripts/register-completions.zsh
@@ -1,10 +1,3 @@
-# zsh parameter completion for the dotnet CLI
-
-_dotnet_zsh_complete()
-{
- local completions=("$(dotnet complete "$words")")
-
- reply=( "${(ps:\n:)completions}" )
-}
-
-compctl -K _dotnet_zsh_complete dotnet
+#compdef dotnet
+local completions=("$(dotnet complete "$words")")
+[[ -n "$completions" ]] && compadd -- "${(ps:\n:)completions}"
--
2.34.1 |
|
It should be still applicable, I'll check and update the PR over the weekend |
Continuing off of PR 13384 in upstream. This commit is ready to be rebased to include appropriate co-authors before merging PR.
|
@dotnet-policy-service agree |
|
@marcpopMSFT @wli3 Please take a look now, I've added |
|
I've also dropped
|
|
This works and works well! I tested by installing zsh in a WSL ubuntu instance and adding the |
|
Chatted with baronfel and we'll merge this and if Omajid has additional feedback we can update with a new PR. Thank you for the contribution and sorry for the delay. |
|
Sorry about the lack of response. I don't use zsh, so I don't have actionable specific advice for this PR itself. I am glad that we are finally shipping a compdef-style completion support with .NET! AFAIK compdef-style completion files are required for completion to work if maintainers want to install them system-wide. |
Taking another look at stuff mentioned in dotnet/cli#13384
I have no knowledge of zsh and completion scripts, just followed the suggestions from aforementioned PR.
Because of that there's few things left to do that come to mind:
fpathsomehow) and what is expected of script files here, inscriptsfolderdotnet completeoutput using zsh completion system's mechanisms of which I know exactly nothing.