dotnet CLI Tab completions now available in 2.0

Tab completion on the command line is like having a superpower for some of the CLI tools we have at our fingertips. With so many commands, paramaters and/or options; it's nice to be able to type a few characters and tap the {Tab} key and get some help. I've gotten spoiled even with directory searching by just hitting tab now in zsh and having the list popup and getting the "pick list" to choose the right one.

A long standing issue for the .NET CLI for the command line lovers was this missing feature. Wait no longer, with the 2.0 release you can now enable it with by adding some config to your .bashrc, .zshrc or even Powershell configurations.

These scripts assume that dotnet v2.0 is on your path.

See the configuration for Powershell and Bash

tab completion image

To enable for zsh:

Edit your .zshrc file and add the following:

_dotnet_zsh_complete()  
{
  local dotnetPath=$words[1]

  local completions=("$(dotnet complete "$words")")

  reply=( "${(ps:\n:)completions}" )
}

compctl -K _dotnet_zsh_complete dotnet  

Restart your zsh terminal instance.

Tweet Post Share Update Email RSS

Hi, I'm Shayne Boyer, I write this site, work on ASP.NET Core content and Open Source, speak at national and community events while helping teams architect web and cloud applications.

Tags:
dotnet dotnet-cli aspnetcore