From 5ed268293365b6b01a1e1c587b690e2252a64748 Mon Sep 17 00:00:00 2001 From: Vas Sudanagunta Date: Sun, 22 Dec 2024 13:16:21 -0500 Subject: [PATCH 1/2] docs: correct incorrect desc and usage in npm-completion.md Fixes #4620 --- docs/lib/content/commands/npm-completion.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/lib/content/commands/npm-completion.md b/docs/lib/content/commands/npm-completion.md index dcc25997fa585..2392199acac5f 100644 --- a/docs/lib/content/commands/npm-completion.md +++ b/docs/lib/content/commands/npm-completion.md @@ -10,10 +10,15 @@ description: Tab Completion for npm ### Description -Enables tab-completion in all npm commands. +Generates a shell script to enable tab-completion for all npm commands. -The synopsis above -loads the completions into your current shell. Adding it to +To load the completions into your current shell: + +```bash +source <(npm completion) +``` + +Adding its output to your ~/.bashrc or ~/.zshrc will make the completions available everywhere: From 4dfeaa113af8e2585aad5befba54ac8c62476a44 Mon Sep 17 00:00:00 2001 From: Vas Sudanagunta Date: Sun, 22 Dec 2024 13:52:59 -0500 Subject: [PATCH 2/2] docs: make npm completion stay in sync with npm updates The current instructions result in a completion script generated by the currently the installed version of npm to be written to the user's shell configuration. If improvements to the script are made in a later npm version, the user will not get these, nor will they know of this condition. The updated instructions regenerates the script from the currently installed version of npm each time the shell initializes, thereby staying in sync. --- docs/lib/content/commands/npm-completion.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/lib/content/commands/npm-completion.md b/docs/lib/content/commands/npm-completion.md index 2392199acac5f..180200193fd44 100644 --- a/docs/lib/content/commands/npm-completion.md +++ b/docs/lib/content/commands/npm-completion.md @@ -18,16 +18,16 @@ To load the completions into your current shell: source <(npm completion) ``` -Adding its output to +Adding this to your ~/.bashrc or ~/.zshrc will make the completions available everywhere: ```bash -npm completion >> ~/.bashrc -npm completion >> ~/.zshrc +echo 'source <(npm completion)' >> ~/.bashrc +echo 'source <(npm completion)' >> ~/.zshrc ``` -You may of course also pipe the output of `npm completion` to a file +You may of course instead add `source <(npm completion)` to a file such as `/usr/local/etc/bash_completion.d/npm` or `/etc/bash_completion.d/npm` if you have a system that will read that file for you.