Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

ng completion

Set up Angular CLI autocompletion for your terminal.

ng

Description 

Setting up autocompletion con�gures your terminal, so pressing the

<TAB> key while in the middle of typing will display various commands

and options available to you. This makes it very easy to discover and

use CLI commands without lots of memorization.


Automated setup
The CLI should prompt and ask to set up autocompletion for you the

�rst time you use it (v14+). Simply answer "Yes" and the CLI will take

care of the rest.


$ ng serve
? you like to enable autocompletion? will
up your terminal so pressing TAB typing
CLI commands will show possible options
autocomplete arguments. ( autocompletion will
modify configuration files your home directory.)

`source <(ng completion script)` to `∕home


∕my-username∕.bashrc`. your terminal run:

source <(ng completion script)

to autocomplete `ng` commands.

# Serve output...

If you already refused the prompt, it won't ask again. But you can run ng

completion to do the same thing automatically.

This modi�es your terminal environment to load Angular CLI

autocompletion, but can't update your current terminal session. Either

restart it or run source <(ng completion script) directly to enable

autocompletion in your current session.

Test it out by typing ng ser<TAB> and it should autocomplete to ng

serve . Ambiguous arguments will show all possible options and their

documentation, such as ng generate <TAB> .

Manual setup
Some users may have highly customized terminal setups, possibly with

con�guration �les checked into source control with an opinionated

structure. ng completion only ever appends Angular's setup to an

existing con�guration �le for your current shell, or creates one if none

exists. If you want more control over exactly where this con�guration
lives, you can manually set it up by having your shell run at startup:

source <(ng completion script)

This is equivalent to what ng completion will automatically set up,

and gives power users more �exibility in their environments when

desired.

Platform support
Angular CLI supports autocompletion for the Bash and Zsh shells on

MacOS and Linux operating systems. On Windows, Git Bash and

Windows Subsystem for Linux  using Bash or Zsh are supported.

Global install
Autocompletion works by con�guring your terminal to invoke the

Angular CLI on startup to load the setup script. This means the terminal

must be able to �nd and execute the Angular CLI, typically through a

global install that places the binary on the user's $PATH . If you get

command not found: ng , make sure the CLI is installed globally which

you can do with the -g �ag:

npm install -g @angular∕cli

This command has the following sub-commands:

• script
Options
VALUE DEFAULT
OPTION DESCRIPTION
TYPE VALUE

--help Shows a help message boolean

for this command in

the console.

Completion commands
script

ng completion

Generate a bash and zsh real-time type-ahead autocompletion script…

You might also like