diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2014-03-03 23:52:20 -0800 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2014-03-03 23:52:20 -0800 |
commit | ff6d8115efaa8d50ec107508c8678ec49d300ed6 (patch) | |
tree | f05ff427c1665d115c903f2f203359f9f730f4c7 /Completion | |
parent | e6d99759e8aff6f17ff08d977c7e7471ac0ebec5 (diff) | |
parent | 3c25cb29aba4d4c1a907aa29db48c36d8dbac18e (diff) | |
download | zsh-ff6d8115efaa8d50ec107508c8678ec49d300ed6.tar.gz zsh-ff6d8115efaa8d50ec107508c8678ec49d300ed6.tar.xz zsh-ff6d8115efaa8d50ec107508c8678ec49d300ed6.zip |
Merge branch 'master' of git://git.code.sf.net/p/zsh/code
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Base/Completer/_extensions | 33 | ||||
-rw-r--r-- | Completion/Base/Core/_main_complete | 8 |
2 files changed, 41 insertions, 0 deletions
diff --git a/Completion/Base/Completer/_extensions b/Completion/Base/Completer/_extensions new file mode 100644 index 000000000..8b6c4fd6a --- /dev/null +++ b/Completion/Base/Completer/_extensions @@ -0,0 +1,33 @@ +#autoload + +# This completer completes filename extensions when completing +# after *. or ^*. It can be used anywhere in the completer list +# but if used after _expand, patterns that already match a file +# will be expanded before it is called. + +compset -P '(#b)([~$][^/]#/|)(*/|)(\^|)\*.' || return 1 + +local -aU files +local -a expl suf mfiles + +files=( ${(e)~match[1]}${match[2]}*.* ) || return 1 +eval set -A files '${(MSI:'{1..${#${(O)files//[^.]/}[1]}}':)files%%.[^/]##}' +files=( ${files:#.<->(.*|)} ) + +if zstyle -t ":completion:${curcontext}:extensions" prefix-hidden; then + files=( ${files#.} ) +else + PREFIX=".$PREFIX" + IPREFIX="${IPREFIX%.}" +fi + +zstyle -T ":completion:${curcontext}:extensions" add-space || + suf=( -S '' ) + +_description extensions expl 'file extension' + +# for an exact match, fail so as to give _expand or _match a chance. +compadd -O mfiles "$expl[@]" -a files +[[ $#mfiles -gt 1 || ${mfiles[1]} != $PREFIX ]] && + compadd "$expl[@]" "$suf[@]" -a files && + [[ -z $compstate[exact_string] ]] diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index 8dd781dbb..e881ea6a1 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -334,6 +334,14 @@ elif [[ nm -eq 0 && -z "$_comp_mesg" && compadd -x "$mesg" fi +if zstyle -s ":completion:${curcontext}:" show-ambiguity tmp; then + local prefix=${${compstate[unambiguous]}[1,${compstate[unambiguous_cursor]}-1]} + local toquote='[=\(\)\|~^?*[\]#<>]' + [[ $tmp = (yes|true|on) ]] && tmp=4 + [[ -n $prefix ]] && + _comp_colors+=( "=(#i)${prefix[1,-2]//?/(}${prefix[1,-2]//(#m)?/${MATCH/$~toquote/\\$MATCH}|)}${prefix[-1]//(#m)$~toquote/\\$MATCH}(#b)(?|)*==$tmp" ) +fi + [[ "$_comp_force_list" = always || ( "$_comp_force_list" = ?* && nm -ge _comp_force_list ) ]] && compstate[list]="${compstate[list]//messages} force" |