-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Fish Shell Suggestions #1173
Comments
Could someone please add the |
Hi, I spent the last two evenings on writing a shim script for Here it is: # dotnet suggest shell complete script start
function _dotnet_fish_complete
# Get current content of the command line
set --local cmd_line (commandline --current-process --tokenize --cut-at-cursor)
# Get full path to script because dotnet-suggest needs it
# NOTE: this requires a command registered with dotnet-suggest be on the PATH
set --local full_path (which $cmd_line[1]) # fish arrays are 1-indexed
# Get the completion results, will be newline-delimited
# `string collect` is used to receive multiline input and leave it like this
set --local completions (dotnet-suggest get --executable "$full_path" -- "$cmd_line" | string collect)
# Return list of completions as content for `complete --arguments`
echo $completions
end
# Apply this function to each command the dotnet-suggest knows about
function _register_dotnet_completions
for cmd in (dotnet-suggest list)
# This is a workaround for the fact that Fish is missing something like compdef (zsh) or complete -F (bash)
# It calls _dotnet_fish_complete when tabbing the respective command,
# which then fills --arguments with a list of the current suggestions generated by `dotnet-suggest`
complete --no-files --command $cmd --arguments '(_dotnet_fish_complete)'
end
end
# Call register function
_register_dotnet_completions
set -x DOTNET_SUGGEST_SCRIPT_VERSION "1.0.0"
# dotnet suggest shell complete script end However, since the It also comes with the following caveats:
Additional thoughs about thisNote: For better understanding how complete --short h --long help --description "Show help and usage information" A more This would probably also mean that one would need to touch Another alternative would be to write a sophisticated I'm also still wrapping my head around how one could achieve this dynamically by constructing the right (I was also wondering where the correct Edit: grammar, typos |
Thanks, @deg0nz! Would you be open to submitting a pull request?
Can you provide some additional details or screenshots here? Are there features that System.CommandLine appears to be missing to provide this experience? We've recently made its completion model richer, though We've also been discussing how best to support richer scripts for specific shells, including approaches like generating scripts that handle many completions without needing to call Regarding file completions, we're planning to include better support for including them in the default System.CommandLine completions (#1697), but as you pointed out this is also an area where specific shells might have better approaches. It's just a bit more work to do something different for each shell and community involvement will be important. |
Hey, @jonsequitur
Sure, can do. I have no experience in
I tried to explain that in the "additional thoughts" section above. What I meant by that was just the fact that Fish suggestions actually look like this: And fish is also able to distinguish between subcommands and flags like so: Those completions rely on more or less complex completion scripts as you can see here in the official Git completion file (This is a very complex example though...) When you look at the
This is exactly what I meant :) |
It would be great if Fish was added to the supported shells for
dotnet-suggest
as documented here.The text was updated successfully, but these errors were encountered: