mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-13 11:21:13 +02:00
zsh-workers/9402
This commit is contained in:
parent
7c10942979
commit
2697c3d52c
3 changed files with 54 additions and 2 deletions
|
@ -28,6 +28,7 @@ styles=(
|
|||
hosts c:_hosts
|
||||
hosts-ports c:host-port
|
||||
hosts-ports-users c:host-port-user
|
||||
ignore-parents c:ignorepar
|
||||
ignored-patterns c:
|
||||
insert-unambiguous c:bool
|
||||
last-prompt c:bool
|
||||
|
@ -167,6 +168,11 @@ while [[ -n $state ]]; do
|
|||
fi
|
||||
;;
|
||||
|
||||
ignorepar)
|
||||
_wanted values expl 'which parents to ignore' &&
|
||||
compadd "$expl[@]" parent pwd .. directory
|
||||
;;
|
||||
|
||||
_*)
|
||||
${=ostate}
|
||||
;;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
local linepath realpath donepath prepath testpath exppath
|
||||
local tmp1 tmp2 tmp3 tmp4 i orig eorig pre suf tpre tsuf opre osuf cpre
|
||||
local pats haspats=no ignore group expl addpfx addsfx remsfx
|
||||
local pats haspats=no ignore group expl addpfx addsfx remsfx rem remt
|
||||
local nm=$compstate[nmatches] menu mspec matcher mopts atmp sort match
|
||||
|
||||
typeset -U prepaths exppaths
|
||||
|
@ -300,8 +300,31 @@ for prepath in "$prepaths[@]"; do
|
|||
tmp2=( ${^tmp1}${^~pats} )
|
||||
[[ ! -o globdots && "$PREFIX" = .* ]] &&
|
||||
tmp2=( "$tmp2[@]" ${^tmp1}.${^~pats} )
|
||||
if (( $#tmp2 )) &&
|
||||
zstyle -s ":completion${curcontext}:files" ignore-parents rem &&
|
||||
[[ ( "$rem" != *dir* || "$pats" = '*(-/)' ) &&
|
||||
( "$rem" != *..* || "$tmp1" = *../* ) ]]; then
|
||||
if [[ "$rem" = *parent* ]]; then
|
||||
for i in "$tmp2[@]"; do
|
||||
if [[ -d "$i" && "$i" = */* ]]; then
|
||||
remt="${i/*}"
|
||||
while [[ "$remt" = */* ]]; do
|
||||
[[ "$remt" -ef "$i" ]] && break
|
||||
remt="${remt%/*}"
|
||||
done
|
||||
[[ "$remt" = */* || "$remt" -ef "$i" ]] &&
|
||||
_comp_ignore=( "$_comp_ignore[@]" "${(q)i}" )
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [[ "$rem" = *pwd* ]]; then
|
||||
for i in "$tmp2[@]"; do
|
||||
[[ "$i" -ef "$PWD" ]] && _comp_ignore=( "$_comp_ignore[@]" "${(q)i}" )
|
||||
done
|
||||
fi
|
||||
fi
|
||||
if [[ "$sopt" = *[/f]* && ( -o globdots || "$PREFIX" = .* ) ]] &&
|
||||
zstyle -s ":completion${curcontext}:paths" special-dirs atmp; then
|
||||
zstyle -s ":completion${curcontext}:paths" special-dirs atmp; then
|
||||
if [[ "$atmp" = (yes|true|1|on) ]]; then
|
||||
tmp2=( "$tmp2[@]" . .. )
|
||||
elif [[ "$atmp" = .. ]]; then
|
||||
|
|
|
@ -876,6 +876,29 @@ item(tt(hosts-ports-users))(
|
|||
Like tt(hosts-ports) but used for commands like tt(telnet) and
|
||||
containing strings of the form `var(host)tt(:)var(port)tt(:)var(user)'.
|
||||
)
|
||||
item(tt(ignore-parents))(
|
||||
When completing files it is possible to make names of directories
|
||||
already mentioned on the line or the current working directory be
|
||||
ignored. The style is tested for the tt(files) tag and if its value
|
||||
contains the string tt(parent), then the name of any directory whose
|
||||
path is already contained in the word on the line is ignored. For
|
||||
example, when completing after tt(foo/../), the directory tt(foo) will
|
||||
not be considered a valid completion.
|
||||
|
||||
If the style contains the string tt(pwd), then the name of the current
|
||||
working directory will not be completed, so that, for example,
|
||||
completion after tt(../) will not use the name of the current
|
||||
directory.
|
||||
|
||||
If the style contains the string tt(..) both tests will only be
|
||||
performed if the word on the line contains the substring tt(../) and
|
||||
if the value contains the string tt(directory), then the tests will
|
||||
only be performed if only names of directories are completed.
|
||||
|
||||
Note that names of directories ignored because of one of the tests
|
||||
will be placed in the alternate set of completions so that they will
|
||||
be completed if there are no other possible completions.
|
||||
)
|
||||
item(tt(ignored-patterns))(
|
||||
This style is used with the tags used when adding matches and gives a
|
||||
number of patterns. All matches that are matched by any of these
|
||||
|
|
Loading…
Reference in a new issue