Last active
May 29, 2023 14:37
-
-
Save Andrew15-5/f407890a21375e07361b8cfd2173f62c to your computer and use it in GitHub Desktop.
bash (`dotnet`) and zsh (`_dotnet`) completion from https://docs.microsoft.com/en-us/dotnet/core/tools/enable-tab-autocomplete#bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zsh parameter completion for the dotnet CLI | |
_dotnet_zsh_complete() | |
{ | |
local completions=("$(dotnet complete "$words")") | |
# If the completion list is empty, just continue with filename selection | |
if [ -z "$completions" ] | |
then | |
_arguments '*::arguments: _normal' | |
return | |
fi | |
# This is not a variable assignment, don't remove spaces! | |
_values = "${(ps:\n:)completions}" | |
} | |
compdef _dotnet_zsh_complete dotnet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bash parameter completion for the dotnet CLI | |
_dotnet_bash_complete() | |
{ | |
local word=${COMP_WORDS[COMP_CWORD]} | |
local completions | |
completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)" | |
if [ $? -ne 0 ]; then | |
completions="" | |
fi | |
COMPREPLY=( $(compgen -W "$completions" -- "$word") ) | |
} | |
complete -f -F _dotnet_bash_complete dotnet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment