summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-10-23 11:02:46 +0300
committerVille Skyttä <ville.skytta@iki.fi>2011-10-23 11:02:46 +0300
commitff8e52c9605fa0a40d642d1ddb57ada11213ac3c (patch)
tree83eed86cf81d0609671dab86bec9b98e7beeb822
parentfa5dbb6c8e724b32575a1c9e949c53f4ed145ea9 (diff)
downloadbash-completion-ff8e52c9605fa0a40d642d1ddb57ada11213ac3c.tar.gz
_init_completion: Complete variable names.
-rw-r--r--bash_completion16
1 files changed, 11 insertions, 5 deletions
diff --git a/bash_completion b/bash_completion
index 4bfa4de8..716c3aaa 100644
--- a/bash_completion
+++ b/bash_completion
@@ -605,11 +605,11 @@ _split_longopt()
return 1
}
-# Initialize completion and deal with redirections: do file completion where
-# appropriate, and adjust prev, words, and cword as if no redirections exist
-# so that completions do not need to deal with them. Before calling this
-# function, make sure cur, prev, words, and cword are local, ditto split if
-# you use -s.
+# Initialize completion and deal with various general things: do file
+# and variable completion where appropriate, and adjust prev, words,
+# and cword as if no redirections exist so that completions do not
+# need to deal with them. Before calling this function, make sure
+# cur, prev, words, and cword are local, ditto split if you use -s.
#
# Options:
# -n EXCLUDE Passed to _get_comp_words_by_ref -n with redirection chars
@@ -644,6 +644,12 @@ _init_completion()
local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)"
_get_comp_words_by_ref -n "$exclude<>&" cur prev words cword
+ # Complete variable names.
+ if [[ $cur == \$* ]]; then
+ COMPREPLY=( $( compgen -P '$' -v -- "${cur#\$}" ) )
+ return 1
+ fi
+
# Complete on files if current is a redirect possibly followed by a
# filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">".
if [[ $cur == $redir* || $prev == $redir ]]; then