_init_completion: Complete variable names.

This commit is contained in:
Ville Skyttä 2011-10-23 11:02:46 +03:00
parent fa5dbb6c8e
commit ff8e52c960

View File

@ -605,11 +605,11 @@ _split_longopt()
return 1 return 1
} }
# Initialize completion and deal with redirections: do file completion where # Initialize completion and deal with various general things: do file
# appropriate, and adjust prev, words, and cword as if no redirections exist # and variable completion where appropriate, and adjust prev, words,
# so that completions do not need to deal with them. Before calling this # and cword as if no redirections exist so that completions do not
# function, make sure cur, prev, words, and cword are local, ditto split if # need to deal with them. Before calling this function, make sure
# you use -s. # cur, prev, words, and cword are local, ditto split if you use -s.
# #
# Options: # Options:
# -n EXCLUDE Passed to _get_comp_words_by_ref -n with redirection chars # -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&])>?(>)|>&)" local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)"
_get_comp_words_by_ref -n "$exclude<>&" cur prev words cword _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 # Complete on files if current is a redirect possibly followed by a
# filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">". # filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">".
if [[ $cur == $redir* || $prev == $redir ]]; then if [[ $cur == $redir* || $prev == $redir ]]; then