-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #20713 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Denys Otrishko <[email protected]>
- Loading branch information
Showing
7 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
const { internalBinding } = require('internal/bootstrap/loaders'); | ||
const { getOptions } = internalBinding('options'); | ||
|
||
function print(stream) { | ||
const { options, aliases } = getOptions(); | ||
const all_opts = [...options.keys(), ...aliases.keys()]; | ||
|
||
stream.write(`_node_complete() { | ||
local cur_word options | ||
cur_word="\${COMP_WORDS[COMP_CWORD]}" | ||
if [[ "\${cur_word}" == -* ]] ; then | ||
COMPREPLY=( $(compgen -W '${all_opts.join(' ')}' -- "\${cur_word}") ) | ||
return 0 | ||
else | ||
COMPREPLY=( $(compgen -f "\${cur_word}") ) | ||
return 0 | ||
fi | ||
} | ||
complete -F _node_complete node node_g`); | ||
} | ||
|
||
module.exports = { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters