summaryrefslogtreecommitdiffstats
path: root/Completion/User
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:20:19 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:20:19 +0000
commit04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8 (patch)
tree2215f99f95d55660fc939a029bf965c454d080b5 /Completion/User
parentzsh-3.1.5-pws-11 (diff)
downloadzsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar
zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.gz
zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.bz2
zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.lz
zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.xz
zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.tar.zst
zsh-04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8.zip
zsh-3.1.5-pws-12zsh-3.1.5-pws-12
Diffstat (limited to 'Completion/User')
-rw-r--r--Completion/User/.distfiles6
-rw-r--r--Completion/User/_a2ps53
-rw-r--r--Completion/User/_configure35
-rw-r--r--Completion/User/_dd2
-rw-r--r--Completion/User/_find8
-rw-r--r--Completion/User/_man2
-rw-r--r--Completion/User/_mh14
-rw-r--r--Completion/User/_rcs1
-rw-r--r--Completion/User/_strip1
-rw-r--r--Completion/User/_tar162
-rw-r--r--Completion/User/_tar_archive20
11 files changed, 193 insertions, 111 deletions
diff --git a/Completion/User/.distfiles b/Completion/User/.distfiles
new file mode 100644
index 000000000..ee0017035
--- /dev/null
+++ b/Completion/User/.distfiles
@@ -0,0 +1,6 @@
+DISTFILES_SRC='
+ .distfiles
+ _a2ps _compress _configure _dd _dvi _find _gunzip _gzip _hosts
+ _make _man _mh _pdf _ps _rcs _rlogin _strip _stty _tar _tar_archive
+ _tex _uncompress _x_options _xfig
+'
diff --git a/Completion/User/_a2ps b/Completion/User/_a2ps
index 600b58872..9923ae20d 100644
--- a/Completion/User/_a2ps
+++ b/Completion/User/_a2ps
@@ -1,22 +1,39 @@
#defcomp a2ps
-if [[ "$PREFIX[1,2]" = -- ]]; then
- _comp_parts '(--borders --compact --truncate-lines --interpret
- --print-anyway --delegate)' '=' '(yes no)'
- _comp_parts '(--major)' '=' '(rows columns)'
- _comp_parts '(--end-of-line)' '=' '(r n nr rn any)'
+# This is for the GNU version of a2ps.
- compgen -S= -k '(--medium --columns --rows --line-numbers
- --font-size --lines-per-page --chars-per-line
- --tabsize --non-printable-format --encoding
- --title --stdin --prologue --highlight-level
- --strip-level --output --version-control --suffix
- --printer --copies --sides --page-prefeed
- --no-page-prefeed)'
- compgen -qS= -k '(--margin --header --underlay --left-title
- --right-title --left-footer --footer --right-footer
- --pages --pretty-print)'
- compgen -k '(--landscape --portrait --catman --no-header)'
-else
- _files -F fignore -g "*~*.ps"
+if [[ "$words[1]" != "$_a2ps_cache_cmd" ]]; then
+ local descr
+
+ _a2ps_cache_cmd="$words[1]"
+
+ descr=( "${(@)${(f@)$($words[1] --list=features)//
+ / }:#}" )
+
+ _a2ps_cache_values=(
+ "${descr[(r)Known style sheets*]#* }"
+ "${descr[(r)Known encodings*]#* }"
+ "${descr[(r)Known media*]#* }"
+ "${descr[(r)Known prologues*]#* }"
+ "${descr[(r)Known PostScript Printer Descriptions*]#* }"
+ "${descr[(r)Known output destination*]#* }"
+ "${descr[(r)Known user options*]#* }"
+ "${descr[(r)Known Variables*]#* }"
+ )
fi
+
+_long_options -t '*\*' '(yes no)' \
+ '*=DIRECTION' '(rows columns)' \
+ '*=TYPE' '(r n nr rn any)' \
+ '--highlight-level*' '(none normal heavy)' \
+ '--version-control*' '(none off t numbered nil
+ existing never simple)' \
+ '--pretty-print*' "[${_a2ps_cache_values[1]}]" \
+ '--encoding*' "(${_a2ps_cache_values[2]})" \
+ '--medium*' "[${_a2ps_cache_values[3]}]" \
+ '--prologue*' "[${_a2ps_cache_values[4]}]" \
+ '--ppd*' "[${_a2ps_cache_values[5]}]" \
+ '--printer*' "[${_a2ps_cache_values[6]}]" \
+ '--user-option*' "[${_a2ps_cache_values[7]}]" \
+ '--variable*' "[${_a2ps_cache_values[8]}]" ||
+ _files -F fignore -g '*~*.(ps|PS|eps|EPS)'
diff --git a/Completion/User/_configure b/Completion/User/_configure
index 050701fac..7559852e8 100644
--- a/Completion/User/_configure
+++ b/Completion/User/_configure
@@ -1,35 +1,4 @@
#defcomp configure
-setopt localoptions extendedglob
-
-if [[ $PREFIX = *=* ]]; then
- # Complete filenames after e.g. --prefix=
- IPREFIX=${PREFIX%%=*}=
- PREFIX=${PREFIX#*=}
- compgen -f
-else
- # Generate a list of options from configure --help
- local -a pars
- local i
- pars=($($words[1] --help | awk '$1 ~ /--[a-z]*.*/ {print $1}'))
- for i in $pars
- do
- case $i in
- (--(((en|dis)able-FEATURE)|(with(out|)-PACKAGE))*)
- : Skip standard help output
- ;;
- --enable)
- : Skip standard help output
- ;;
- --*\[=* )
- compadd -M 'r:|-=* r:|=*' -q -S = -- ${i%%\[=*}
- ;;
- --*=* )
- compadd -M 'r:|-=* r:|=*' -S = -- ${i%%=*}
- ;;
- * )
- compadd -M 'r:|-=* r:|=*' -- $i
- ;;
- esac
- done
-fi
+_long_options '*=(E|)PREFIX*' '_files -/' \
+ '*=PROGRAM*' '_command_names'
diff --git a/Completion/User/_dd b/Completion/User/_dd
index 86a47b1ab..63ae40f50 100644
--- a/Completion/User/_dd
+++ b/Completion/User/_dd
@@ -5,7 +5,7 @@ if [[ -iprefix conv= ]]; then
# test alone will have that effect.
[[ -string , ]]
compgen -S, -q \
- -k '(ascii ebcdic ibm block unblock lcase ucase swab noerror sync)'
+ -k '(ascii ebcdic ibm block unblock lcase ucase swab noerror sync)'
elif [[ -iprefix 'if=' || -iprefix 'of=' ]]; then
_files
else
diff --git a/Completion/User/_find b/Completion/User/_find
index 8fcdafb83..cb637fc26 100644
--- a/Completion/User/_find
+++ b/Completion/User/_find
@@ -10,8 +10,12 @@ elif [[ -iprefix - ]]; then
{i,}{l,}name {no,}{user,group} path perm regex size true uid used \
exec {f,}print{f,0,} ok prune ls'
elif [[ -position 2 ]]; then
- compgen -g '. ..'
- _files -g '(-/)'
+ local ret=1
+
+ compgen -g '. ..' && ret=0
+ _files -g '(-/)' && ret=0
+
+ return ret
elif [[ "$prev" = -((a|c|)newer|fprint(|0|f)) ]]; then
_files
elif [[ "$prev" = -fstype ]]; then
diff --git a/Completion/User/_man b/Completion/User/_man
index 67d59f24a..cd1badc4d 100644
--- a/Completion/User/_man
+++ b/Completion/User/_man
@@ -1,7 +1,9 @@
#defcomp man
+
setopt localoptions rcexpandparam
local rep
+
if [[ $words[2] = (<->*|ln) ]]; then
rep=( $manpath/(man|cat)${words[2]}/$PREFIX*$SUFFIX.<->*(N:t:r) )
else
diff --git a/Completion/User/_mh b/Completion/User/_mh
index 7e8575123..c6c018220 100644
--- a/Completion/User/_mh
+++ b/Completion/User/_mh
@@ -4,6 +4,7 @@
# Alter the following two to your own mh directory and the directory
# where standard mh library files live. (It works anyway, but this
# will save a little time.)
+
local mymhdir=~/Mail
local mhlib=/usr/lib/mh
@@ -25,6 +26,7 @@ if [[ -iprefix - ]]; then
elif [[ -iprefix '+' || -iprefix '@' || "$prev" = -draftfolder ]]; then
# Complete folder names.
local mhpath
+
if [[ $IPREFIX != '@' ]]; then
[[ $IPREFIX = '+' ]] || IPREFIX=+
mhpath=$mymhdir
@@ -53,7 +55,8 @@ elif [[ "$prev" = -[rw]cache ]]; then
compadd public private never ask
else
# Generate sequences.
- local foldnam folddir f
+ local foldnam folddir f ret
+
for f in $argv; do
[[ $f = [@+]* ]] && foldnam=$f
done
@@ -66,7 +69,10 @@ else
# leaving foldnam empty works here
fi
- compgen -s '$(mark $foldnam 2>/dev/null | awk -F: '\''{ print $1 }'\'')'
- compadd reply next cur prev first last all unseen
- compgen -W folddir -g '<->'
+ compgen -s '$(mark $foldnam 2>/dev/null | awk -F: '\''{ print $1 }'\'')' &&
+ ret=0
+ compadd reply next cur prev first last all unseen && ret=0
+ compgen -W folddir -g '<->' && ret=0
+
+ return ret
fi
diff --git a/Completion/User/_rcs b/Completion/User/_rcs
index 5a751605c..5e53cb4da 100644
--- a/Completion/User/_rcs
+++ b/Completion/User/_rcs
@@ -6,6 +6,7 @@ local nm=$compstate[nmatches]
if [[ $compstate[nmatches] -eq nm && -d RCS && $words[1] != ci ]]; then
local rep
+
rep=(RCS/$PREFIX*$SUFFIX,v(:t:s/\,v//))
(( $#rep )) && compadd - $rep
fi
diff --git a/Completion/User/_strip b/Completion/User/_strip
index 6962ac455..541c901ad 100644
--- a/Completion/User/_strip
+++ b/Completion/User/_strip
@@ -1,2 +1,3 @@
#defcomp strip
+
_files -g '*(*)'
diff --git a/Completion/User/_tar b/Completion/User/_tar
index 84c490f1e..d11ee76c8 100644
--- a/Completion/User/_tar
+++ b/Completion/User/_tar
@@ -1,69 +1,125 @@
#defcomp tar
# Tar completion. Features:
-# - Assumes tar commands are in second position, tar archive is in third
-# e.g. tar xvzf zsh-3.0.5.tar.gz ...
-# Could search better. Send me the patch.
+# - Tries to collect tar commands from second position, single letter
+# option, and long options.
# - `tar' can be called anything, will use the correct name
-# - Preferentially completes *.tar and *.TAR files in third position
-# - unless z or Z appears in the commands, in which case prefer *.tar.gz
-# and similar (GNU tar).
-# - From fourth position on, if command is x or t, completes files inside
-# archive. This is supposed to look pretty much as if the files are
-# in an ordinary directory hierarchy. Handles extraction from compressed
-# archives (GNU tar).
+# - Uses the function `_tar_archive' to complete archive files.
+# - Tries to find out if compressed archives should be used.
+# - Completes files inside archive. This is supposed to look pretty
+# much as if the files are in an ordinary directory hierarchy.
+# Handles extraction from compressed archives (GNU tar).
# - Anywhere -- appears, gets a list of long options to complete from
-# tar itself (GNU tar); this needs perl. If you have GNU tar but not
-# perl: your system manager is weird.
+# tar itself (GNU tar)
# - Things like --directory=... are also completed correctly.
emulate -LR zsh
setopt extendedglob
-local nm=$NMATCHES tcmd="$words[2]" tf="$words[3]"
+local _tar_cmd tf tmp del
-if [[ $PREFIX = *=* ]]; then
- # For GNU tar arguments like --directory=
- IPREFIX=${PREFIX%%\=*}=
- PREFIX=${PREFIX#*=}
- if [[ $IPREFIX = --directory* ]]; then
- _path_files -/
- else
- _files
+# First we collect in `_tar_cmd' single letter options describing what
+# should be done with the archive and if it is compressed. This
+# collected from options arguments that start with only one hyphen,
+# from some of the possible long options, and from the second word if
+# that does not start with a hyphen.
+
+tmp=("${(@M)words:#-[^-]*}")
+_tar_cmd="${(j::)tmp#-}"
+
+(( $words[(I)--(un|)gzip] )) && _tar_cmd="z$_tar_cmd"
+(( $words[(I)--(un|)compress] )) && _tar_cmd="Z$_tar_cmd"
+(( $words[(I)--list] )) && _tar_cmd="t$_tar_cmd"
+(( $words[(I)--(extract|get)] )) && _tar_cmd="x$_tar_cmd"
+(( $words[(I)--create] )) && _tar_cmd="c$_tar_cmd"
+
+# Other ways of finding out what we're doing: first
+# look in the first argument if it's not an option
+if [[ "$words[2]" = *[txcdruA]*~-* ]]; then
+ _tar_cmd="$words[2]$_tar_cmd"
+elif [[ $_tar_cmd != *[txcdruA]* && CURRENT -gt 2 ]]; then
+ # look for more obscure long options: these aren't all handled.
+ (( $words[(I)--(diff|compare)] )) && _tar_cmd="d$_tar_cmd"
+ (( $words[(I)--append] )) && _tar_cmd="r$_tar_cmd"
+ (( $words[(I)--update] )) && _tar_cmd="u$_tar_cmd"
+ (( $words[(I)--(con|)catenate] )) && _tar_cmd="A$_tar_cmd"
+ (( $words[(I)--delete] )) && del=1
+fi
+
+# Next, we try to find the archive name and store it in `tf'. The name
+# is searched after a `--file=' long option, in the third word if the
+# second one didn't start with a hyphen but contained a `f', and after
+# an option argument starting with only one hyphen and containing a `f'.
+
+tmp="$words[(I)--file=*]"
+if (( tmp )); then
+ tf="${words[tmp][8,-1]}"
+ _tar_cmd="f$_tar_cmd"
+elif [[ "$words[2]" != -* && "$words[2]" = *f* ]]; then
+ tf="$words[3]"
+ _tar_cmd="f$_tar_cmd"
+else
+ tmp="${words[(I)-*f*~--*]}"
+ if (( tmp )); then
+ tf="$words[tmp+1]"
+ _tar_cmd="f$_tar_cmd"
fi
-elif [[ $PREFIX = --* ]]; then
- # gnu tar, generate completions from --help
- # ones followed by = get that as a suffix
- local -a ownlist eqlist
- local comp
- $words[1] --help |
- perl -ne 'while (/--[^[\s,='\'']+=?/g) { print "$&\n"; }' |
- while read comp; do
- if [[ $comp = *= ]]; then
- eqlist[$#eqlist+1]=${comp%=}
- else
- ownlist[$#ownlist+1]=$comp
- fi
- done
- compgen -S '=' -k eqlist
- compgen -k ownlist
-elif [[ "$tcmd" = *[tx]*f* && $CURRENT -ge 4 ]] then
- # Listing or extracting a particular file. We run `tar t...'
- # on the file, keeping the list of filenames cached, plus the
- # name of the tarfile so we know if it changes.
+fi
+
+# Now we complete...
+
+if [[ "$PREFIX" = --* ]]; then
+
+ # ...long options after `--'.
+
+ _long_options '--owner*' "_tilde" \
+ '*=(PROG|COMMAND)*' "_command_names" \
+ '*=ARCHIVE*' "_tar_archive" \
+ '*=CONTROL*' "[t numbered nil existing never simple]"
+
+elif [[ ( CURRENT -gt 2 && "$words[CURRENT-1]" = -*f* &&
+ "$words[CURRENT-1]" != --* ) ||
+ ( CURRENT -eq 3 && "$words[2]" = *f* && "$words[2]" != -* ) ]]; then
+
+ # ...archive files if we think they are wanted here.
+
+ _tar_archive
+
+elif [[ ( "$_tar_cmd" = *[xt]* || -n $del ) && -n "$tf" ]]; then
+
+ # ...and files from the archive if we found an archive name and tar
+ # commands. We run `tar t...' on the file, keeping the list of
+ # filenames cached, plus the name of the tarfile so we know if it
+ # changes.
+
local largs=-tf
- [[ $words[2] = *z* ]] && largs=-tzf
- [[ $words[2] = *Z* ]] && largs=-tZf
- if [[ $tf != $tar_cache_name ]]; then
- tar_cache_list=("${(@f)$($words[1] $largs $tf)}")
- tar_cache_name=$tf
+ if [[ $_tar_cmd = *z* ]]; then
+ largs=-tzf
+ elif [[ $_tar_cmd = *Z* ]]; then
+ largs=-tZf
+ else
+ # Some random compression program e.g. bzip2
+ tmp="${words[(r)--use-comp*]}"
+ [[ -n $tmp ]] && largs=($tmp -tf)
+ fi
+
+ if [[ $tf != $_tar_cache_name ]]; then
+ _tar_cache_list=("${(@f)$($words[1] $largs $tf)}")
+ _tar_cache_name=$tf
+ fi
+
+ _multi_parts / _tar_cache_list
+else
+
+ # See if we should use a path prefix. We have to use eval as the dir can
+ # be any unevaluated thing which appears on the command line, including a
+ # parameter.
+ tmp=${words[(r)--dir[a-z]#=*]}
+ if [[ -n $tmp ]]; then
+ eval "tmp=(${tmp#*=})"
+ _path_files -W tmp
+ else
+ _files
fi
- _multi_parts / tar_cache_list
-elif [[ "$tcmd" = *c*f* && $CURRENT -ge 4 ]] then
- _files
-elif [[ "$tcmd" = *[zZ]*f* && $CURRENT -eq 3 ]] then
- _files -g '*.((tar|TAR).(gz|Z)|.tgz)'
-elif [[ "$tcmd" = *f* && $CURRENT -eq 3 ]] then
- _files -g '*.(tar|TAR)'
fi
diff --git a/Completion/User/_tar_archive b/Completion/User/_tar_archive
new file mode 100644
index 000000000..58e436c4d
--- /dev/null
+++ b/Completion/User/_tar_archive
@@ -0,0 +1,20 @@
+#autoload
+
+# This is used to generate filenames usable as a tar archive. This may
+# get one argument, a collection of tar option characters that may be
+# used to find out what kind of filename is needed. If no argument is
+# given but the parameter `_tar_cmd' is set, that is used.
+# If your version of `tar' supports this you may want to complete
+# things like `host:file' or `user@host:file' here.
+
+[[ $# -eq 0 && $+_tar_cmd -ne 0 ]] && set "$_tar_cmd"
+
+if [[ "$1" = *[tx]* ]]; then
+ if [[ "$1" = *[zZ]* ]]; then
+ _files -g '*.((tar|TAR).(gz|GZ|Z)|.tgz)'
+ else
+ _files -g '*.(tar|TAR)'
+ fi
+else
+ _files
+fi