Skip to content

Commit

Permalink
src: add "missing" bash completion options
Browse files Browse the repository at this point in the history
Currently, when using the bash completions for node the normal
completions for filenames directories do not work. For example, after
finding a node completion and then wanting to use tab completion
for a filename in the test directory, it is only possible to get the
name of the test directory completed, followed by a space. What is
expected is to be able to continue with tab completion for directories.

This commit adds options to the complete command to enable default bash
completions.

PR-URL: #33744
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
  • Loading branch information
danbev committed Jun 8, 2020
1 parent 7f8e977 commit 813368c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ std::string GetBashCompletion() {
" return 0\n"
" fi\n"
"}\n"
"complete -F _node_complete node node_g";
"complete -o filenames -o nospace -o bashdefault "
"-F _node_complete node node_g";
return out.str();
}

Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-bash-completion.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const suffix = `' -- "\${cur_word}") )
return 0
fi
}
complete -F _node_complete node node_g`.replace(/\r/g, '');
complete -o filenames -o nospace -o bashdefault -F _node_complete node node_g`
.replace(/\r/g, '');

assert.ok(
output.includes(prefix),
Expand Down

0 comments on commit 813368c

Please sign in to comment.