diff options
author | Ville Skyttä <ville.skytta@iki.fi> | 2011-10-25 20:15:13 +0300 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-10-25 20:15:13 +0300 |
commit | 3b029892f6f9db3b7210a7f66d636be3e5ec5fa2 (patch) | |
tree | 32e5467d973ac0922cbd3db18001b7cc8f729cc9 | |
parent | 1bdf31c894835ecd28ba196a7f2d6e1b467010cf (diff) | |
download | bash-completion-dynamic-loading.tar.gz |
_init_completion: Improve variable name completion.dynamic-loading
Complete only things that look like variable names to make things like
$HOME/<TAB> and $(<TAB> pass through, and fix completion of variables
enclosed in braces.
-rw-r--r-- | bash_completion | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bash_completion b/bash_completion index eb5fffcf..1656a714 100644 --- a/bash_completion +++ b/bash_completion @@ -645,8 +645,10 @@ _init_completion() _get_comp_words_by_ref -n "$exclude<>&" cur prev words cword # Complete variable names. - if [[ $cur == \$* ]]; then - COMPREPLY=( $( compgen -P '$' -v -- "${cur#\$}" ) ) + if [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then + [[ $cur == *{* ]] && local suffix=} || local suffix= + COMPREPLY=( $( compgen -P ${BASH_REMATCH[1]} -S "$suffix" -v -- \ + "${BASH_REMATCH[2]}" ) ) return 1 fi |