From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1452 invoked by alias); 22 Jan 2014 16:49:40 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32300 Received: (qmail 12155 invoked from network); 22 Jan 2014 16:49:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Biglobe-Sender: From: "Jun T." Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: [PATCH] new completion function for od Message-Id: <769D8A10-B6C7-49D7-BF7C-4CBB5980F8A9@kba.biglobe.ne.jp> Date: Thu, 23 Jan 2014 00:59:03 +0900 To: zsh-workers@zsh.org Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) X-Mailer: Apple Mail (2.1827) --- This is a new completion function for the od (octal dump) command Completion/Unix/Command/_od | 71 = +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Completion/Unix/Command/_od diff --git a/Completion/Unix/Command/_od b/Completion/Unix/Command/_od new file mode 100644 index 0000000..d542597 --- /dev/null +++ b/Completion/Unix/Command/_od @@ -0,0 +1,71 @@ +#compdef od + +local context state state_descr line args ret=3D1 +local -A opt_args + +args=3D( + '(-A --address-radix)'{-A+,--address-radix=3D}'[file offset = base]:base:((d\:decimal o\:octal x\:hexadecimal n\:none))' + '(-j --skip-bytes)'{-j+,--skip-bytes=3D}'[skip specified = bytes]:bytes' + '(-N --read-bytes)'{-N+,--read-bytes=3D}'[dump at most specified = bytes]:bytes' + '*'{-t+,--format=3D}'[specify output format]:format string:->format' + '(-v --output-duplicates)'{-v,--output-duplicates}'[do not use * to = mark line suppression]' + '-a[output named characters (-t a)]' + '-b[output octal bytes (-t o1)]' + '-c[output characters with C-style escape (-t c)]' + '-d[output unsigned decimal shorts (-t u2)]' + '-f[output single-precision floats (-t fF)]' + {-h,-x}'[output hexadecimal shorts (-t x2)]' + '-i[output decimal integers (-t dI)]' + {-l,-I,-L}'[output decimal longs (-t dL)]' + {-o,-B}'[output octal shorts (-t o2)]' + '-s[output decimal shorts (-t d2)]' + '*:files:_files' +) + +if _pick_variant gnu=3DGNU unix --version; then + # -h -B -I and -L are obsolescent and undocumented + args=3D( ${(R)args:#(|\*)(|\(*\))-[hBIL]*} ) + args+=3D( + {-S+,--strings=3D-}'[output strings of at least specfied bytes = long]:length' + {-w-,--width=3D-}'[output specified bytes per line]:bytes' + '(- : *)--help[display help and exit]' + '(- : *)--version[output version information and exit]' + ) +else + args=3D( ${(R)args:#(|\*)(|\(*\))--*} ) # remove long options + case "$OSTYPE" in + (darwin*|freebsd*|dragonfly*|openbsd*) + args+=3D( + '-D[output unsigned decimal ints (-t u4)]' + {-e,-F}'[output double-precision floats (-t fD)]' + {-H,-X}'[output hexadecimal ints (-t x4)]' + '-O[output octal ints (-t o4)]' + ) + ;; + (*) + # POSIX options only + args=3D( ${(M)args:#(|\*)(|\(*\))-[AjNtvbcdosx]*} ) + ;; + esac +fi + +_arguments -s -S : "$args[@]" && return 0 + +case "$state" in + (format) + compset -P '*[acCSIL1248FDL]' + if compset -P '*[doux]'; then + args=3D( 'C:char' 'S:short' 'I:int' 'L:long' 1 2 4 8 ) + _describe -t integer-size 'size of integer' args && ret=3D0 + elif compset -P '*f'; then + args=3D( 'F:float' 'D:double' 'L:long double' ) + _describe -t float-size 'size of float' args && ret=3D0 + fi + args=3D( 'a:named character' 'c:character (C-style escape)' + 'd:decimal' 'o:octal' 'u:unsigned decimal' + 'x:hexadecimal' 'f:floating-point number' ) + _describe -t type-specifier 'type specifier' args && ret=3D0 + ;; +esac + +return ret --=20 1.8.3.4 (Apple Git-47)