Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: more completion funcs



This adds the _sed and _uniq that I've had lying around for a while. I
had hoped to do something intelligent for sed expressions but the
completion system gets into a mess with quoted newlines.

I've also updated ssh-keygen completion and added descriptions for rar
commands.

Index: Completion/Unix/Command/_rar
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_rar,v
retrieving revision 1.3
diff -u -r1.3 _rar
--- Completion/Unix/Command/_rar	21 Jan 2004 13:53:29 -0000	1.3
+++ Completion/Unix/Command/_rar	23 Feb 2004 16:42:37 -0000
@@ -22,10 +22,10 @@
   '-ow[save or restore file owner and group]'
   '-p\-[do not query password]'
   '-r[recurse subdirectorie]'
-  '-ta[process files modified after <date> in YYYYMMDDHHMMSS format]'
-  '-tb[process files modified before <date> in YYYYMMDDHHMMSS format]'
-  '-tn[process files newer than <time>]'
-  '-to[process files older than <time>]'
+  '-ta+[process files modified after a date]:date (YYYYMMDDHHMMSS)'
+  '-tb+[process files modified before a date]:date (YYYYMMDDHHMMSS)'
+  '-tn+[process files newer than a specified time]:time'
+  '-to+[process files older than a specified time]:time'
   '-u[update files]'
   '-v[create volumes with size autodetection or list all volumes]'
   '-ver[file version control]'
@@ -44,10 +44,33 @@
   ;;
   rar)
     if (( CURRENT == 2 )); then
-      _wanted commands expl 'rar command' compadd \
-	  a c cf cw d e f i k l lt m mf p r rc rr rv s t u v vt x && return
+      _values 'rar command' \
+	'a[add files to archive]' \
+	'c[add archive comment]' \
+	'cf[add files comment]' \
+	'cw[write archive comment to file]' \
+	'd[delete files from archive]' \
+	'e[extract files to current directory]' \
+	'f[freshen files in archive]' \
+	'i[find string in archives]' \
+	'k[lock archive]' \
+	'l[list archive]' \
+	'lt[list archive (technical format)]' \
+	'm[move to archive]' \
+	'mf[move to archive (files only)]' \
+	'p[print file to stdout]' \
+	'r[repair archive]' \
+	'rc[reconstruct missing volumes]' \
+	'rr[add data recovery record]' \
+	'rv[create recovery volumes]' \
+	's[convert archive to or from SFX]' \
+	't[test archive files]' \
+	'u[update files in archive]' \
+	'v[verbosely list archive]' \
+	'vt[verbosely list archive (technical format)]' \
+	'x[extract files with full path]' && return
     else
-      _arguments -s \
+      _arguments -S \
 	'-ag[generate archive name using the current date]' \
 	'-as[synchronize archive contents]' \
 	'-av[put authenticity verification (registered versions only)]' \
Index: Completion/Unix/Command/_sed
===================================================================
RCS file: Completion/Unix/Command/_sed
diff -N Completion/Unix/Command/_sed
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_sed	23 Feb 2004 16:42:37 -0000
@@ -0,0 +1,27 @@
+#compdef sed
+
+local args
+
+args=(
+  '(-n --quiet --silent)'{-n,--quiet,--silent}'[suppress automatic printing of pattern space]'
+  '(1)*'{-e,--expresssion=}'[add sed commands to run]:sed script'
+  '(1)*'{-f,--file=}'[add contents of file to commands to run]:file:_files'
+  '(-e)1: :_guard "^-*" sed script'
+  ':input file:_files'
+)
+
+if _pick_variant gnu=GNU unix --version; then
+  args+=(
+    '(-i --in-place)'{-i,--in-place=}'[edit files in place]::suffix for backup'
+    '(-l --line-length)'{-l,--line-length=}'[specify line-wrap length for the l command]'
+    '(-r --regexp-extended)'{-r,--regexp-extended}'[use extended regular expressions]'
+    '(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]'
+    '(-u --unbuffered)'{-u,--unbuffered}'[disable data buffering]'
+    '(- 1 :)--help[print program usage]'
+    '(- 1 :)'{-V,--version}'[print program version]'
+  )
+else
+  args=( "${(@)args:#(|\(*\))(|\*)--*}" )
+fi
+
+_arguments "$args[@]"
Index: Completion/Unix/Command/_ssh
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_ssh,v
retrieving revision 1.20
diff -u -r1.20 _ssh
--- Completion/Unix/Command/_ssh	7 May 2003 12:44:52 -0000	1.20
+++ Completion/Unix/Command/_ssh	23 Feb 2004 16:42:37 -0000
@@ -4,9 +4,9 @@
   # There should be coloring based on all the different ls -F classifiers.
   local expl remfiles remdispf remdispd args suf ret=1
 
-  if zstyle -T ":completion:${curcontext}:" remote-access; then
+  if zstyle -T ":completion:${curcontext}:files" remote-access; then
     zparseopts -D -E -a args p: 1 2 4 6 F:
-    remfiles=(${(M)${(f)"$(ssh $args -a -x ${IPREFIX%:} ls -d1F ${(Q)PREFIX%%[^./][^/]#}\* 2>/dev/null)"}%%[^/]#(|/)})
+    remfiles=(${(M)${(f)"$(_call_program files ssh $args -a -x ${IPREFIX%:} ls -d1F ${(Q)PREFIX%%[^./][^/]#}\* 2>/dev/null)"}%%[^/]#(|/)})
     compset -P '*/'
     compset -S '/*' || suf='remote file'
 
@@ -29,7 +29,7 @@
 }
 
 _ssh () {
-  local curcontext="$curcontext" state line expl common tmp ret=1
+  local curcontext="$curcontext" state line expl common tmp cmds suf ret=1
   typeset -A opt_args
 
   common=(
@@ -82,8 +82,8 @@
       '-v[verbose mode]' \
       '-B[batch mode]' \
       '-q[disables the progress meter]' \
-      '-P+[specify port on remote host]:port number on remote host:' \
-      '-S+[specify path to ssh]:path to ssh:_files -g \*\(-\*\)' \
+      '-P+[specify port on remote host]:port number on remote host' \
+      '-S+[specify ssh program]:path to ssh:_command_names -e' \
       '*:file:->file' "$common[@]" && ret=0
     ;;
   ssh-add)
@@ -106,21 +106,24 @@
     return
     ;;
   ssh-keygen)
+    cmds=( -p -i -e -y -c -l -B -D -U )
     _arguments \
-      '(-p -c -u -P)-b[specify number of bits in key]:bits in key:' \
-      '(-c)-f[key file]:key file:_files' \
-      '(-c -u)-N[specify new passphrase]:new passphrase:' \
-      '(-b -u -f)-P[specify old passphrase]:old passphrase:' \
-      '(-p -u)-C[specify new comment]:new comment:' \
-      '(-b -C -u -c)-p[change passphrase of private key file]' \
-      '(-b -N -p -u)-c[change comment in private and public key files]' \
-      '-l[show fingerprint of specified private or public key file]' \
       '-q[silence ssh-keygen]' \
-      '-R[exit 0 or 1 if RSA support is functional]' \
-      '-x[read a DSA private key and print a SSH2 public key to stdout]'\
-      '-X[read a SSH2 public key and print a DSA public key to stdout]'\
-      '-y[read a DSA private key and print a DSA public key to stdout]'\
-      '(-b -N -C -p -c)-u[change key cipher to default]'
+      "($cmds -P)-b[specify number of bits in key]:bits in key" \
+      "($cmds -P)-t[specify the type of the key to create]:key type:(rsa1 rsa dsa)" \
+      "(${cmds#-p })-N[provide new passphrase]:new passphrase" \
+      "($cmds -b -t)-C[provide new comment]:new comment" \
+      '(-D)-f[key file]:key file:_files' \
+      '('${(j. .)cmds:#-[pc]}' -t -b)-P[provide old passphrase]:old passphrase' \
+      "($cmds -q -b -t -C)-p[change passphrase of private key file]" \
+      "($cmds -q -b -t -N -C -P)-i[import key to OpenSSH format]" \
+      "($cmds -q -b -t -N -C -P)-e[export key to SECSH file format]" \
+      "($cmds -q -b -t -N -C -P)-y[get public key from private key]" \
+      "($cmds -q -b -t -N)-c[change comment in private and public key files]" \
+      "($cmds -q -b -t -N -C -P)-l[show fingerprint of key file]" \
+      "($cmds -q -b -t -N -C -P)-B[show the bubblebabble digest of key]" \
+      "($cmds -q -b -t -N -C -P -f)-D[download key stored in smartcard reader]:reader" \
+      "($cmds -q -b -t -N -C -P)-U[upload key to smartcard reader]:reader"
     return
     ;;
   sftp)
@@ -129,6 +132,7 @@
       '-F+[specify alternate config file]:config file:_files' \
       '(-1)-s[invoke subsystem]' \
       '-S+[specify program]:program:_command_names -e' \
+      '-B+[specify buffer size]:buffer size' \
       '-b+[specify batch file to read]:batch file:_files' \
       '*-v[verbose mode]' \
       '-1[forces ssh to try protocol version 1 only]' \
@@ -265,7 +269,9 @@
       if compset -P '*:'; then
         _remote_files ${(kv)~opt_args[(I)-[FP1246]]/-P/-p} && ret=0
       elif compset -P '*@'; then
-        _wanted hosts expl host _ssh_hosts -S: && ret=0
+        suf=( -S '' )
+        compset -S ':*' || suf=( -S : )
+        _wanted hosts expl host _ssh_hosts $suf && ret=0
       else
         _alternative \
 	    'files:: _files' \
Index: Completion/Unix/Command/_uniq
===================================================================
RCS file: Completion/Unix/Command/_uniq
diff -N Completion/Unix/Command/_uniq
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_uniq	23 Feb 2004 16:42:37 -0000
@@ -0,0 +1,26 @@
+#compdef uniq
+
+local args
+
+args=(
+  '(-c --count)'{-c,--count}'[prefix lines by the number of occurrences]'
+  '(-d --repeated)'{-d,--repeated}'[only print duplicate lines]'
+  '(-D --all-repeated)'{-D,--all-repeated=}'[print all duplicate lines]:delimit method:(none prepend separate)'
+  '(-f --skip-fields)'{-f,--skip-fields=}'[avoid comparing initial fields]:number of fields'
+  '(-i --ignore-case)'{-i,--ignore-case}'[ignore differences in case when comparing]'
+  '(-s --skip-chars)'{-s,--skip-chars=}'[avoid comparing initial characters]:number of characters'
+  '(-t --separator)'{-t,--separator=}'[specify field delimiter]:separator'
+  '(-u --unique)'{-u,--unique}'[only print unique lines]'
+  '(-w --check-chars)'{-w,--check-chars=}'[specify maximum number of characters to compare]:characters'
+  '(-W --check-fields)'{-W,--check-fields=}'[specify maximum number of fields to compare]:fields'
+  '(- *)--help[display help information]'
+  '(- *)--version[display version information]'
+)
+
+if ! _pick_variant gnu=Free\ Soft unix --version; then
+  args=( ${(M)args:#(|\*)(|\(*\))-[cdufs]*} )
+fi
+
+_arguments "$args[@]" \
+  '1::input file:_files' \
+  '2::output file:_files'



Messages sorted by: Reverse Date, Date, Thread, Author