diff options
-rw-r--r-- | Completion/Base/_condition | 48 | ||||
-rw-r--r-- | Src/Zle/zle_tricky.c | 10 |
2 files changed, 54 insertions, 4 deletions
diff --git a/Completion/Base/_condition b/Completion/Base/_condition index 5e599a53c..b6a4eff7a 100644 --- a/Completion/Base/_condition +++ b/Completion/Base/_condition @@ -1,11 +1,55 @@ #compdef -condition- -local prev="$words[CURRENT-1]" +local prev="$words[CURRENT-1]" ret=1 if [[ "$prev" = -o ]]; then _tags -C -o options && _options elif [[ "$prev" = -([a-hkprsuwxLOGSN]|[no]t|ef) ]]; then _tags -C "$prev" files && _files else - _alternative 'files:: _files' 'parameters:: _parameters' + if [[ "$PREFIX" = -* ]] || + ! zstyle -T ":completion:${curcontext}:options" prefix-needed; then + + if [[ "$prev" = (\[\[|\|\||\&\&|\!|\() ]]; then + _describe -o 'condition code' \ + '( -a:existing\ file + -b:block\ special\ file + -c:character\ special\ file + -d:directory + -e:existing\ file + -f:regular\ file + -g:setgid\ bit + -h:symbolic\ link + -k:sticky\ bit + -n:non-empty\ string + -o:option + -p:named\ pipe + -r:readable\ file + -s:non-empty\ file + -t:terminal\ file\ descriptor + -u:setuid\ bit + -w:writable\ file + -x:executable\ file + -z:empty\ string + -L:symbolic\ link + -O:own\ file + -G:group-owned\ file + -S:socket + -N:unread\ file)' && ret=0 + else + _describe -o 'condition code' \ + '( -nt:newer\ than + -ot:older\ than + -ef:same\ file + -eq:numerically\ equal + -ne:numerically\ not\ equal + -lt:numerically\ less\ than + -le:numerically\ less\ then\ or\ equal + -lt:numerically\ greater\ than + -le:numerically\ greater\ then\ or\ equal)' && ret=0 + fi + fi + _alternative 'files:: _files' 'parameters:: _parameters' && ret=0 + + return ret fi diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 12fd58b4f..464e6607e 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -978,7 +978,7 @@ get_comp_string(void) * this would be to pass the command line through the parser too, * * and get the arguments that way. Maybe in 3.1... */ do { - lincmd = ((incmdpos && !ins) || (oins == 2 && i == 2) || + lincmd = ((incmdpos && !ins && !incond) || (oins == 2 && i == 2) || (ins == 3 && i == 1)); linredir = (inredir && !ins); oins = ins; @@ -1023,7 +1023,7 @@ get_comp_string(void) if (tok == ENDINPUT) break; if ((ins && (tok == DO || tok == SEPER)) || - (ins == 2 && i == 2) || (ins == 3 && i == 3) || + (ins == 2 && i == 2) || (ins == 3 && i == 3) || tok == BAR || tok == AMPER || tok == BARAMP || tok == AMPERBANG || ((tok == DBAR || tok == DAMPER) && !incond)) { @@ -1060,6 +1060,12 @@ get_comp_string(void) inwhat = IN_COND; } else if (linredir) continue; + if (incond) { + if (tok == DBAR) + tokstr = "||"; + else if (tok == DAMPER) + tokstr = "&&"; + } if (!tokstr) continue; /* Hack to allow completion after `repeat n do'. */ |