From 3b029892f6f9db3b7210a7f66d636be3e5ec5fa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Tue, 25 Oct 2011 20:15:13 +0300 Subject: _init_completion: Improve variable name completion. Complete only things that look like variable names to make things like $HOME/ and $( pass through, and fix completion of variables enclosed in braces. --- bash_completion | 6 ++++-- 1 file 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 -- cgit v1.2.1