Skip to content
Myr

[Refactor] `bash_completion`: Improve coding style

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Peter Dave Hello · committed by Jordan Harband · parent 113d807 · Browse files · 1 file+28 added−35 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+28 added−35 removed

  • other:+28 added−35 removed

1 file+28 added−35 removed

modified:bash_completion+28 added-35 removed
1 unmodified line
23# bash completion for Node Version Manager (NVM)45if ! command -v nvm &> /dev/null; then6 return6 return7fi89__nvm_generate_completion()10{9__nvm_generate_completion() {10 declare current_word11 current_word="${COMP_WORDS[COMP_CWORD]}"12 # shellcheck disable=SC220714 COMPREPLY=($(compgen -W "$1" -- "$current_word"))13 COMPREPLY=($(compgen -W "$1" -- "${current_word}"))14 return 015}1618__nvm_commands ()19{17__nvm_commands() {18 declare current_word19 declare command2021 current_word="${COMP_WORDS[COMP_CWORD]}"
5 unmodified lines
27 install-latest-npm28 cache deactivate unload29 version version-remote which'3033 if [ ${#COMP_WORDS[@]} == 4 ]; then31 if [ ${#COMP_WORDS[@]} == 4 ]; then3235 command="${COMP_WORDS[COMP_CWORD-2]}"36 case "${command}" in37 alias) __nvm_installed_nodes ;;38 esac33 command="${COMP_WORDS[COMP_CWORD - 2]}"34 case "${command}" in35 alias) __nvm_installed_nodes ;;36 esac3740 else38 else3942 case "${current_word}" in43 -*) __nvm_options ;;44 *) __nvm_generate_completion "$COMMANDS" ;;45 esac40 case "${current_word}" in41 -*) __nvm_options ;;42 *) __nvm_generate_completion "${COMMANDS}" ;;43 esac4447 fi45 fi46}4750__nvm_options ()51{48__nvm_options() {49 OPTIONS=''53 __nvm_generate_completion "$OPTIONS"50 __nvm_generate_completion "${OPTIONS}"51}5256__nvm_installed_nodes ()57{53__nvm_installed_nodes() {54 __nvm_generate_completion "$(nvm_ls) $(__nvm_aliases)"55}5661__nvm_aliases ()62{57__nvm_aliases() {58 declare aliases59 aliases=""65 if [ -d "$NVM_DIR/alias" ]; then66 aliases="$(cd "$NVM_DIR/alias" && command find "$PWD" -type f | command sed "s:$PWD/::")"60 if [ -d "${NVM_DIR}/alias" ]; then61 aliases="$(cd "${NVM_DIR}/alias" && command find "${PWD}" -type f | command sed "s:${PWD}/::")"62 fi63 echo "${aliases} node stable unstable iojs"64}6571__nvm_alias ()72{66__nvm_alias() {67 __nvm_generate_completion "$(__nvm_aliases)"68}6976__nvm ()77{70__nvm() {71 declare previous_word79 previous_word="${COMP_WORDS[COMP_CWORD-1]}"72 previous_word="${COMP_WORDS[COMP_CWORD - 1]}"7381 case "$previous_word" in82 use|run|exec|ls|list|uninstall) __nvm_installed_nodes ;;83 alias|unalias) __nvm_alias ;;84 *) __nvm_commands ;;74 case "${previous_word}" in75 use | run | exec | ls | list | uninstall) __nvm_installed_nodes ;;76 alias | unalias) __nvm_alias ;;77 *) __nvm_commands ;;78 esac7980 return 081}
10 unmodified lines