Skip to content
Myr

bash_completion

This file

Path

bash_completion

96 lines · 1.9 KiB

Last changed by

[Fix] bash_completion should make sure nvm loadedPeter Dave Hellobefore adoption952d006

History of this file

Take it

The walk stopped after 200 commits: lines older than 1ca2aa6 point at it.

[minor] Echo nonwritable file path to stderr.Jordan Harbandbefore adoption1ca2aa6

lines 1–4why, one step back
1#!/usr/bin/env bash
23# bash completion for Node Version Manager (NVM)4

[Fix] bash_completion should make sure nvm loadedPeter Dave Hellobefore adoption952d006

lines 5–8why, one step back
5if ! nvm &> /dev/null; then
6 return7fi8

[minor] Echo nonwritable file path to stderr.Jordan Harbandbefore adoption1ca2aa6

lines 9–23why, one step back
9__nvm_generate_completion()
10{11 declare current_word12 current_word="${COMP_WORDS[COMP_CWORD]}"13 COMPREPLY=($(compgen -W "$1" -- "$current_word"))14 return 015}1617__nvm_commands ()18{19 declare current_word20 declare command2122 current_word="${COMP_WORDS[COMP_CWORD]}"23

[shellcheck] SC1004,SC2086 fixes in bash_completionPeter Dave Hellobefore adoption9963660

lines 24–28why, one step back
24 COMMANDS='
25 help install uninstall use run exec26 alias unalias reinstall-packages27 current list ls list-remote ls-remote28 clear-cache deactivate unload

[minor] Echo nonwritable file path to stderr.Jordan Harbandbefore adoption1ca2aa6

lines 29–62why, one step back
29 version which'
3031 if [ ${#COMP_WORDS[@]} == 4 ]; then3233 command="${COMP_WORDS[COMP_CWORD-2]}"34 case "${command}" in35 alias) __nvm_installed_nodes ;;36 esac3738 else3940 case "${current_word}" in41 -*) __nvm_options ;;42 *) __nvm_generate_completion "$COMMANDS" ;;43 esac4445 fi46}4748__nvm_options ()49{50 OPTIONS=''51 __nvm_generate_completion "$OPTIONS"52}5354__nvm_installed_nodes ()55{56 __nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"57}5859__nvm_aliases ()60{61 declare aliases62 aliases=""

[shellcheck] SC1004,SC2086 fixes in bash_completionPeter Dave Hellobefore adoption9963660

lines 63–64why, one step back
63 if [ -d "$NVM_DIR/alias" ]; then
64 aliases="$(cd "$NVM_DIR/alias" && command find "$PWD" -type f | command sed "s:$PWD/::")"

[minor] Echo nonwritable file path to stderr.Jordan Harbandbefore adoption1ca2aa6

line 65why, one step back
65 fi

Merge pull request #1070 from ljharb/display_lts_remoteJordan Harbandbefore adoptiondbb65d9

line 66why, one step back
66 echo "${aliases} node stable unstable iojs"

[minor] Echo nonwritable file path to stderr.Jordan Harbandbefore adoption1ca2aa6

lines 67–91why, one step back
67}
6869__nvm_alias ()70{71 __nvm_generate_completion "$(__nvm_aliases)"72}7374__nvm ()75{76 declare previous_word77 previous_word="${COMP_WORDS[COMP_CWORD-1]}"7879 case "$previous_word" in80 use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;;81 alias|unalias) __nvm_alias ;;82 *) __nvm_commands ;;83 esac8485 return 086}8788# complete is a bash builtin, but recent versions of ZSH come with a function89# called bashcompinit that will create a complete in ZSH. If the user is in90# ZSH, load and run bashcompinit before calling the complete function.91if [[ -n ${ZSH_VERSION-} ]]; then

fix/retab indent in bash_completion [no-ci]Peter Dave Hellobefore adoption7ef38cf

line 92why, one step back
92 autoload -U +X bashcompinit && bashcompinit

[minor] Echo nonwritable file path to stderr.Jordan Harbandbefore adoption1ca2aa6

lines 93–96why, one step back
93fi
9495complete -o default -o nospace -F __nvm nvm96