You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: This article teaches you how to enable tab completion for the .NET CLI for PowerShell, Bash, zsh, fish, and nushell.
3
+
description: This article teaches you how to enable tab completion for the .NET CLI for PowerShell (pwsh), Bash, zsh, fish, and nushell.
4
4
author: adegeo
5
5
ms.author: adegeo
6
6
ms.topic: how-to
7
-
ms.date: 07/06/2023
7
+
ms.date: 11/14/2025
8
+
ai-usage: ai-assisted
8
9
---
9
10
10
11
# How to enable tab completion for the .NET CLI
11
12
12
-
**This article applies to:** ✔️ .NET Core 2.1 SDK and later versions
13
+
**This article applies to:** ✔️ .NET 6 SDK and later versions
13
14
14
-
This article describes how to configure tab completion for five shells: PowerShell, Bash, zsh, fish, and nushell. For other shells, refer to their documentation on how to configure tab completion.
15
+
This article describes how to configure tab completion for five shells: PowerShell (pwsh), Bash, zsh, fish, and nushell. For other shells, refer to their documentation on how to configure tab completion.
16
+
17
+
## Native shell completion scripts (.NET 10+)
18
+
19
+
Starting with .NET 10, the .NET CLI includes native shell completion scripts that run much faster than the dynamic completions available in earlier versions. Native completions generate shell-specific scripts that handle the static parts of the CLI grammar directly in the shell, providing a significant performance improvement.
20
+
21
+
### Generate completion scripts
22
+
23
+
Use the `dotnet completions generate` command to generate a completion script for your shell:
24
+
25
+
```console
26
+
dotnet completions generate [SHELL]
27
+
```
28
+
29
+
The `[SHELL]` parameter accepts one of the following values:
30
+
31
+
-`bash`
32
+
-`fish`
33
+
-`nushell`
34
+
-`pwsh`
35
+
-`zsh`
36
+
37
+
If you don't specify a shell, the command infers the correct shell from your environment. On Windows, it defaults to PowerShell (`pwsh`). On other systems, it checks if the file name of the `SHELL` environment variable matches any of the supported shell values.
38
+
39
+
### Completion capabilities
40
+
41
+
Native completions provide different levels of support depending on the shell:
42
+
43
+
| Shell | Completion type | Descriptions in tab completions |
-**Hybrid**: Generates shell-specific code that handles static parts of the CLI grammar quickly, but falls back to the `dotnet complete` command for dynamic content (such as NuGet package IDs).
54
+
-**Dynamic**: All completions go through the `dotnet complete` command, which might be slower but ensures comprehensive coverage.
55
+
56
+
### Configure shells to use native completions
57
+
58
+
Add the appropriate command to your shell's profile to enable native completions:
59
+
60
+
#### PowerShell
61
+
62
+
Add the following line to your PowerShell profile (`$PROFILE`):
Add the following line to your `config.fish` file:
87
+
88
+
```fish
89
+
dotnet completions generate fish | source
90
+
```
91
+
92
+
#### Nushell
93
+
94
+
Add the following to the beginning of your `config.nu` file:
95
+
96
+
```nu
97
+
dotnet completions generate nushell | save -f ~/.local/share/nushell/completions/dotnet.nu
98
+
use ~/.local/share/nushell/completions/dotnet.nu *
99
+
```
100
+
101
+
## Dynamic completion scripts (all versions)
102
+
103
+
For .NET versions prior to .NET 10, or if you prefer to use dynamic completions, you can configure your shell to use the `dotnet complete` command. Dynamic completions work by sending the current command line to the `dotnet complete` command and processing the results in the shell.
15
104
16
105
Once set up, tab completion for the .NET CLI is triggered by entering a `dotnet` command in the shell and then pressing the <kbd>Tab</kbd> key. The current command line is sent to the `dotnet complete` command, and the results are processed by the shell. You can test the results without enabling tab completion by sending something directly to the `dotnet complete` command. For example:
17
106
@@ -26,19 +115,19 @@ pack
26
115
27
116
If that command doesn't work, make sure that .NET Core 2.0 SDK or later is installed. If it's installed but that command still doesn't work, make sure that the `dotnet` command resolves to a version of .NET Core 2.0 SDK or later. Use the `dotnet --version` command to see what version of `dotnet` your current path is resolving to. For more information, see [Select the .NET version to use](../versions/selection.md).
28
117
29
-
## Examples
118
+
###Examples
30
119
31
120
Here are some examples of what tab completion provides:
To add tab completion to **PowerShell** for the .NET CLI, create or edit the profile stored in the variable `$PROFILE`. For more information, see [How to create your profile](/powershell/module/microsoft.powershell.core/about/about_profiles#how-to-create-a-profile) and [Profiles and execution policy](/powershell/module/microsoft.powershell.core/about/about_profiles#profiles-and-execution-policy).
0 commit comments