From a22485d8f117c82b300eee81fef64b858bf73bb5 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Mon, 14 May 2018 13:09:27 +0200 Subject: [PATCH] tools: add bash completion for node This commit adds a --completion-bash option to node which can be sourced to provide bash code completion for node options. Usage: $ node --completion-bash > node_bash_completion $ source node_bash_completion $ node --[tab] PR-URL: https://github.com/nodejs/node/pull/20713 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Denys Otrishko --- doc/api/cli.md | 11 +++++++++++ doc/node.1 | 3 +++ lib/internal/bash_completion.js | 25 +++++++++++++++++++++++++ lib/internal/bootstrap/node.js | 8 +++++++- node.gyp | 1 + src/node_options.cc | 3 +++ src/node_options.h | 1 + 7 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 lib/internal/bash_completion.js diff --git a/doc/api/cli.md b/doc/api/cli.md index 8adb33efb7b06e..3f5441b82e7ce8 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -52,6 +52,17 @@ If this flag is passed, the behavior can still be set to not abort through [`process.setUncaughtExceptionCaptureCallback()`][] (and through usage of the `domain` module that uses it). +### `--completion-bash` + + +Print source-able bash completion script for Node.js. +```console +$ node --completion-bash > node_bash_completion +$ source node_bash_completion +``` + ### `--enable-fips`