Commit Graph
29 Commits
Author SHA1 Message Date
Peter Dave HelloandJordan Harband bea27fbe0f [New] bash_completion: complete options and arguments in context
Parse words before the cursor once to offer flags, versions, and aliases
in the positions that accept them. Distinguish install options before
and after the version, and leave run and exec arguments to the shell.

Match local names literally. Account for Readline splitting at `=` and
quoting common prefixes. Give zsh the same candidates as raw strings so
its line editor can match, quote, and close arguments in its own syntax.

Check the offered flags against nvm help and cover argument boundaries,
including the actual arguments submitted by zsh after Tab completion.

Co-authored-by: Peter Dave Hello <hsu@peterdavehello.org>
Co-authored-by: Jordan Harband <ljharb@gmail.com>
2026-11-25 13:23:26 -08:00
Jordan Harband 6b9650c47f [Fix] bash_completion: list alias and version names without expanding them
`__nvm_generate_completion` passed its word list to `compgen -W`,
which runs every word through shell expansion.
Since that list includes alias file names and installed version directory names,
pressing Tab after `nvm use`, `nvm alias`, etc,
ran any command substitution in those names,
expanded variables in them, and globbed `*` against the current directory.
Now the list is split with globbing disabled,
and each word is matched against the current word as a literal prefix,
so names are offered exactly as written

Discovered by Anthropic's OSS Scanner, as bug ANT-2026-QDARMGPO; the scanner correctly classified it as not a vulnerability.
2026-10-22 20:10:42 -07:00
Gilad Barnea d91087c333 [Fix] bash_completion: be robust when cd is overridden 2021-09-13 15:26:40 +03:00
akefirad 117486d4a7 [Fix] bash_completion: check if compinit is called before calling it
Fixes #2489.
2021-04-16 18:53:35 +02:00
hjoshi123 f3fa157456 [Fix] bash_completion: move compinit before bashcompinit 2020-12-29 08:35:08 +05:30
Nathan Burchill 0c2efed407 [New] bash_completion: Add support for ZSH_DISABLE_COMPFIX flag.
When using Oh My Zsh the ZSH_DISABLE_COMPFIX flag allows the zsh completion system to use files it deems to be insecure.
2018-09-18 16:15:35 -04:00
Peter Dave Hello 62ee7cf998 [Refactor] bash_completion: Improve coding style 2018-05-21 19:59:01 +08:00
Brian M. Jemilo II 68fe26a5e4 [Fix] Add autocompletion support to zsh
Fixes #1707.
2018-04-09 14:54:28 -05:00
easyaspi314 (Devin) d8689f6b9a bash_completion: Reduce startup time 2018-03-12 10:41:05 -04:00
Peter Dave Hello 2cd2c0f72e Remove useless trailing newlines 2018-02-26 01:01:30 +08:00
Peter Dave Hello fce7f4ed13 [Fix] Disable ShellCheck SC2207 in bash_completion line 14 2017-12-14 02:11:50 +08:00
Peter Dave Hello b5034bb2b2 [bash completion] add missing install-latest-npm; remove undocumented clear-cache 2017-06-23 14:21:10 +08:00
Peter Dave Hello 6c24346af5 [New] Add missing commands in bash_completion 2017-03-30 19:49:30 +08:00
Peter Dave Hello 676fff0219 [completions] Remove nospace in bash_completion 2017-03-26 06:10:53 +08:00
Peter Dave Hello 952d0067b3 [Fix] bash_completion should make sure nvm loaded 2017-03-15 14:34:28 +08:00
Peter Dave Hello 9963660a11 [shellcheck] SC1004,SC2086 fixes in bash_completion 2016-11-24 15:59:16 +08:00
Peter Dave Hello eab41ed8ef [Fix] add missing "command" prefix call for some commands 2016-11-13 04:53:41 +08:00
Peter Dave Hello 7ef38cf7e8 fix/retab indent in bash_completion [no-ci] 2016-11-11 19:43:36 +08:00
Jordan Harband fb49bf6f70 completion: add LTS aliases. 2016-07-18 23:40:32 -07:00
Jordan Harband 4c475b2767 Use the original ls instead of aliases.
Fixes #755
2015-05-29 11:11:14 -07:00
Jordan Harband e58d4abf11 Add bash_completion for nvm exec 2015-02-16 00:39:05 -08:00
Jordan Harband fc3a30dd0e Add nvm which to bash_completion 2014-12-17 01:29:38 -08:00
Jordan Harband e728577627 Rename nvm copy-packages to nvm reinstall-packages, and --copy-packages-from install option to --reinstall-packages-from
For #341. `nvm copy-packages` and install option `--copy-packages-from` will continue to be supported for for at least a full minor release version.
2014-11-22 13:22:24 -08:00
Jordan Harband fda05fb64b Remove trailing whitespace. 2014-09-29 14:26:19 -07:00
Jordan Harband 9aec19a692 Update bash completion commands for nvm 2014-09-28 16:50:49 -07:00
Jordan Harband 3a21485050 Files should end in trailing newlines 2014-03-15 11:41:50 -07:00
Christopher Roach 205117bed4 Fixes issue 199
Fixes issue 199 where the bash completion was not working in ZSH
because the builtin bash command `complete` was not found. The fix
executes the `bashcompinit` command which creates the `complete`
function for the Z shell.
2013-03-01 10:55:58 -08:00
mikedeboer c4a13dd2b6 updated list of commands 2012-10-17 16:50:05 +00:00
Rafael Magana cfa81b49d1 bash completion 2012-04-09 01:25:49 -05:00