
- Angular CLI Tutorial
- Angular CLI - Home
- Angular CLI - Overview
- Angular CLI - Environment Setup
- Angular CLI Commands
- Angular CLI - ng version
- Angular CLI - ng new
- Angular CLI - ng help
- Angular CLI - ng generate
- Angular CLI - ng build
- Angular CLI - ng run
- Angular CLI - ng serve
- Angular CLI - ng lint
- Angular CLI - ng test
- Angular CLI - ng e2e
- Angular CLI - ng add
- Angular CLI - ng analytics
- Angular CLI - ng config
- Angular CLI - ng doc
- Angular CLI - ng update
- Angular CLI - ng xi18n
- Angular CLI - Code Coverage
- Angular CLI - ng cache Command
- Angular CLI - ng completion Command
- Angular CLI - ng deploy Command
- Angular CLI - ng extracti18n Command
- Angular CLI Useful Resources
- Angular CLI - Quick Guide
- Angular CLI - Useful Resources
- Angular CLI - Discussion
Angular CLI - ng completion Command
This chapter explains the Angular CLI ng completion command. It includes syntax, arguments, options, and an example to show how to use this command in an angular application to enable auto-completion.
The 'ng completion' Command
The Angular CLI (Command Line Interface) provide a command called ng completion, which is used to enable shell auto-completion for angular commands and options.
It helps developers to work more efficiently by providing suggestions in the terminal. When you press the
Important! When you run your Angular application very first time using the ng serve command, CLI should prompt and ask to set up autocompletion. If you refuse it once, it will not ask again. But you can run the ng completion command to do the same thing automatically.
Syntax
Following is the syntax of the Angular CLI ng completion command −
ng completion[options]
Here,
- options: It shows a help message for this command in the console.
Arguments
It does not require any argument.
Options
Below is a list of a few commonly used options:
Sr.No. | Options & Description |
---|---|
1 |
--all
It generates a completion script of all the available shells. |
2 |
--bash
Generates a completion script specific to the 'bash shell'. |
3 |
--zsh
Generates a completion script specific to the 'zsh shell'. |
4 |
--fish
Generates a completion script specific to the 'fish shell'. |
5 |
script:
Generate a 'bash' and 'zsh' real-time type-ahead autocompletion script. |
Example
The following is an example of using the "ng completion" command in an Angular application −
ng completion
When you run the above command in a code editor terminal or Command Prompt (on a Windows operating system), you might observe the following error:
PS C:\Users\Tutorialspoint\Desktop\Angular Practice\myApp> ng completion `$SHELL` environment variable not set. Angular CLI autocompletion only supports Bash or Zsh. If you're on Windows, Cmd and Powershell don't support command autocompletion, but Git Bash or Windows Subsystem for Linux should work, so please try again in one of those environments.
The above error confirms that the command prompt and windows PowerShell don't use directly this command, if you want to proceed with it, make sure the git Bash is installed in your system. Then re-enter the ng completion command to see the changes.
To use the "ng completion" command (in window operating system) use the following steps:
Step 1: Download the git-bash from the below link:
Download Git Bash
Step 2: Open the downloaded file and install it in your system.
Step 3: Open the Git Bash:

Step 4: Run the following command in the Git Bash terminal:
ng completion

Step 5: Restart your terminal or run the following command:
source <(ng completion script)
Once the above command runs successfully, you will be able to see:

Step 6: Now enter the ng and press the <TAB> key to show available commands:

As you can see in the above image, all commands become available by pressing the TAB key after entering 'ng', since we have already enabled shell auto-completion for Angular.
To test for autocomplete, simply start typing ng ser<TAB>, and it should autocomplete to ng serve as follows:
