Enable AutoComplete for C# .NET on Linux

This blog post will learn how to enable Dotnet CLI (C#) command Autocomplete on Linux bash shell.

Dotnet CLI

With Bash shell on Linux, it is very common for most tools, including bash shell, commands to use Autocomplete to complete commands by using the tab key.

Dotnet CLI also has this feature, and we will go ahead and enable it. To get started, open the .bashrc using the following command.

sudo nano .bashrc

Scroll down to the last line and paste the following code into the file. Restart the shell using the following command and give it a go.

  local word=${COMP_WORDS[COMP_CWORD]}

  local completions
  completions="$(dotnet complete --position "${COMP_POINT}" "${COMP_LINE}" 2>/dev/null)"
  if [ $? -ne 0 ]; then

  COMPREPLY=( $(compgen -W "$completions" -- "$word") )

complete -f -F _dotnet_bash_complete dotnet

To reload the bash shell, use the following command.

exec -l $SHELL
Categorized as C#, C# 9

Leave a comment

Your email address will not be published.