summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-10-25 20:15:13 +0300
committerVille Skyttä <ville.skytta@iki.fi>2011-10-25 20:15:13 +0300
commit3b029892f6f9db3b7210a7f66d636be3e5ec5fa2 (patch)
tree32e5467d973ac0922cbd3db18001b7cc8f729cc9
parent1bdf31c894835ecd28ba196a7f2d6e1b467010cf (diff)
downloadbash-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_completion6
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