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

PATCH: completions for less, wiggle, merge, attr



This is a few more completion functions: less I assume you've heard of.
merge is the RCS merge tool so has gone in _rcs. wiggle is similar but
patch based. Finally, there is completion for attr, setfattr and
getfattr which set extended attributes on files.

Oliver

Index: Completion/Unix/Command/_attr
===================================================================
RCS file: Completion/Unix/Command/_attr
diff -N Completion/Unix/Command/_attr
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_attr	1 Mar 2004 11:46:06 -0000
@@ -0,0 +1,47 @@
+#compdef attr getfattr setfattr
+
+case $service in
+  attr)
+    local -a list
+    [[ $OSTYPE = irix* ]] &&
+        list=( '(-g -s -r -V)-l[list extended attributes associated with file]' )
+    _arguments -s -S "$list[@]" \
+      '(-l -r -s -V)-g[get extended attribute for file]:attribute name' \
+      '(-l -g -s -q -V)-r[remove given attribute from file]:attribute name' \
+      '(-l -g -r)-s[set named attribute for file]:attribute name' \
+      '(-r)-q[quiet output]' \
+      '(-g -r)-V[specify value of attribute]:value' \
+      '-L[dereference symbolic links]' \
+      '-R[operator in the root attribute namespace]' \
+      '1:file:_files'
+    return
+  ;;
+  getfattr)
+    _arguments -s -S \
+      '(-d --dump -n --name)'{-n+,--name=}'[dump the value of the named extended attribute]' \
+      '(-n --name -d --dump)'{-d,--dump}'[dump the values of all extended attributes]' \
+      '(-e --encoding)'{-e+,--encoding=}'[encode values after retrieving them]:encoding:(text hex base64)' \
+      '(-h --no-derference)'{-h,--no-dereference}'[do not follow symbolic links]' \
+      '(-m --match)'{-m+,--match=}'[only include attributes with names matching regex]:regular expression' \
+      '--absolute-names[do not string leasing slash characters]' \
+      '--only-values[dump only attribute values]' \
+      '(-R --recursive)'{-R,--recursive}'[list attributes of all files and directories recurively]' \
+      '(-P --physical -L --logical)'{-L,--logical}'[follow all symbolic links]' \
+      '(-L --logical -P --physical)'{-P,--physical}'[skip all symbolic links]' \
+      '(* -)--version[display version information]' \
+      '(* -)--help[display help information]' \
+      '*:file:_files'
+    return
+  ;;
+  setfattr)
+    _arguments -s -S \
+      '(-n --name)'{-n+,--name=}'[specify extended attribute to set]' \
+      '(-v --value)'{-v+,--value=}'[specify value for the attribute]' \
+      '(-x --remove)'{-x+,--remove=}'[remove specified extended attribute]' \
+      '(-n --name -v --value)--restore[restore extended attributes from dump file]:dump file:_files' \
+      '(-h --no-derference)'{-h,--no-dereference}'[do not follow symbolic links]' \
+      '(* -)--version[display version information]' \
+      '(* -)--help[display help information]' \
+      '*:file:_files'
+    return
+esac
Index: Completion/Unix/Command/_less
===================================================================
RCS file: Completion/Unix/Command/_less
diff -N Completion/Unix/Command/_less
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_less	1 Mar 2004 11:46:06 -0000
@@ -0,0 +1,112 @@
+#compdef less -value-,LESS,-default- -value-,LESSCHARSET,-default-
+
+local curcontext="$curcontext" state line expl ret=1
+local -a files
+
+case $service in
+  *LESSCHARSET*)
+    _wanted charsets expl 'character set' compadd ascii iso8859 latin1 latin9 \
+        dos ebcdic IBM-1047 koi8-r next utf-8
+    return
+  ;;
+  *LESS*)
+    compset -q
+    words=( fake "$words[@]" )
+    (( CURRENT++ ))
+  ;;
+  *)
+    files=( '*:file:_files' )
+  ;;
+esac
+
+if compset -P '+[-0-9]#'; then
+  _describe 'less command' '(
+    g:goto\ line
+    F:scroll\ to\ end\ and\ keep\ reading\ file
+    G:go\ to\ end\ of\ file
+    %:go\ to\ position\ in\ file 
+    p:go\ to\ position\ in\ file 
+  )'
+  return
+fi
+
+_arguments -S -s -A "[-+]*"  \
+  '(-? --help)'{-\?,--help}'[display summary of less commands]' \
+  '(-a --search-skip-screen)'{-a,--search-skip-screen}'[begin forward searches after last displayed line]' \
+  '(-b --buffers)'{-b+,--buffers=}'[specify amount of buffer space used for each file]:buffer space (kilobytes)' \
+  '(-B --auto-buffers)'{-B,--auto-buffers}"[don't automatically allocate buffers for pipes]" \
+  '(-C --CLEAR-SCREEN -c --clear-screen)'{-c,--clear-screen}'[repaint screen instead of scrolling]' \
+  '(-c --clear-screen -C --CLEAR-SCREEN)'{-C,--CLEAR-SCREEN}'[clear screen before repaints]' \
+  '(-d --dumb)'{-d,--dumb}'[suppress error message if terminal is dumb]' \
+  '(-e -E --quit-at-eof --QUIT-AT-EOF)'{-e,--quit-at-eof}'[exit the second time end-of-file is reached]' \
+  '(-e -E --quit-at-eof --QUIT-AT-EOF)'{-E,--QUIT-AT-EOF}'[exit when end-of-file is reached]' \
+  '(-f --force)'{-f,--force}'[force opening of non-reqular files]' \
+  '(-F --quit-if-one-screen)'{-F,--quit-if-one-screen}'[exit if entire file fits on first screen]' \
+  '(-G --HILITE-SEARCH -g --hilite-search)'{-g,--hilite-search}'[highlight only one match for searches]' \
+  '(-g --hilite-search -G --HILITE-SEARCH)'{-G,--HILITE-SEARCH}'[disable highlighting of search matches]' \
+  '(-h --max-back-scroll)'{-h+,--max-back-scroll=}'[specify backward scroll limit]:backward scroll limit (lines)' \
+  '(-I --IGNORE-CASE -i --ignore-case)'{-i,--ignore-case}'[ignore case in searches that lack uppercase]' \
+  '(-i --ignore-case -I --IGNORE-CASE)'{-I,--IGNORE-CASE}'[ignore case in all searches]' \
+  '(-j --jump-target)'{-j+,--jump-target}'[specify screen position of target lines]:position (line)' \
+  '(-J --status-column)'{-J,--status-column}'[display status column on the left]' \
+  \*{-k+,--lesskey-file=}'[use specified lesskey file]:lesskey file:_files' \
+  '(-L --no-lessopen)'{-L,--no-lessopen}'[ignore the LESSOPEN environment variable]' \
+  '(-M --LONG-PROMPT -m --long-prompt)'{-m,--long-prompt}'[prompt verbosely]' \
+  '(-m --long-prompt -M --LONG-PROMPT)'{-M,--LONG-PROMPT}'[prompt very verbosely]' \
+  '(-N --LINE-NUMBERS -n --line-numbers)'{-n,--line-numbers}"[don't keep track of line numbers]" \
+  '(-n --line-numbers -N --LINE-NUMBERS)'{-N,--LINE-NUMBERS}'[show line numbers]' \
+  '(* -O --LOG-FILE -o --log-file)'{-o+,--log-file=}'[copy input to file]:file:_files' \
+  '(* -o --log-file -O --LOG-FILE)'{-O+,--LOG-FILE=}'[copy input to file, overwriting if necessary]:file:_files' \
+  '(-p --pattern)'{-p+,--pattern=}'[start at specified pattern]:pattern' \
+  \*{-P+,--prompt=}'[specify prompt format]:prompt:->prompts' \
+  '(-Q --QUIET --SILENT -q --quiet --silent)'{-q,--quiet,--silent}'[never use bell]' \
+  '(-q --quiet --silent -Q --QUIET --SILENT)'{-Q,--QUIET,--SILENT}'[limit use of bell]' \
+  '(-r -R --raw-control-chars --RAW-CONTROL-CHARS)'{-r,--raw-control-chars}'[display raw control characters]' \
+  '(-r -R --raw-control-chars --RAW-CONTROL-CHARS)'{-R,--RAW-CONTROL-CHARS}'[display control chars; keep track of screen effects]' \
+  '(-s --squeeze-blank-lines)'{-s,--squeeze-blank-lines}'[squeeze consecutive blank lines down to one]' \
+  '(-S --chop-long-lines)'{-S,--chop-long-lines}'[truncate long lines instead of folding]' \
+  '(-t --tag)'{-t+,--tag=}'[edit file containing tag]:tag:->tags' \
+  '(-T --tag-file)'{-T+,--tag-file=}'[specify tags file]:tags file:_files' \
+  '(-u --underline-special)'{-u,--underline-special}'[send backspaces and carriage returns to the terminal]' \
+  '(-U --UNDERLINE-SPECIAL)'{-U,--UNDERLINE-SPECIAL}'[treat backspaces, tabs and carriage returns as control characters]' \
+  '(* -)'{-V,--version}'[display version information]' \
+  '(-W --HILITE-UNREAD -w --hilite-unread)'{-w,--hilite-unread}'[highlight first unread line after forward page]' \
+  '(-w --hilite-unread -W --HILITE-UNREAD)'{-W,--HILITE-UNREAD}'[highlight first unread line after forward movement]' \
+  '(-x --tabs)'{-x+,--tabs=}'[set tab stops]:tab stops' \
+  '(-X --no-init)'{-X,--no-init}'[disable use of terminal init string]' \
+  '--no-keypad[disable use of keypad terminal init string]' \
+  '(-y --max-forw-scroll)'{-y,--max-forw-scroll}'[specify forward scroll limit]' \
+  '(-z --window)'{-z+,--window=}'[specify scrolling window size]:lines' \
+  '(-\" --quotes)'{-\"+,--quotes=}'[change quoting character]:quoting characters' \
+  '(-~ --tilde)'{-~,--tilde}"[don't display tildes after end of file]" \
+  '(-\# --shift)'{-\#+,--shift=}"[specify amount to move when scrolling horizontally]:number" \
+  "$files[@]" && ret=0
+
+
+if [[ -n "$state" ]]; then
+  case $state in
+    prompt)
+      if compset -P \?; then
+	_message -e prompt
+      else
+	_describe 'prompt' '(
+	  s:short\ prompt
+	  m:medium\ prompt
+	  M:long\ prompt
+	  h:help\ screen\ prompt
+	  \=:\=\ command\ prompt
+	  w:waiting\ prompt
+	)' && ret=0
+      fi
+    ;;
+    tags)
+      if (( $+LESSGLOBALTAGS )); then
+        _global_tags
+      else
+        _message -e ctags tag
+      fi
+    ;;
+  esac
+fi
+
+return ret
Index: Completion/Unix/Command/_rcs
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_rcs,v
retrieving revision 1.2
diff -u -r1.2 _rcs
--- Completion/Unix/Command/_rcs	12 Nov 2002 14:43:18 -0000	1.2
+++ Completion/Unix/Command/_rcs	1 Mar 2004 11:46:06 -0000
@@ -1,8 +1,20 @@
-#compdef co ci rcs rcsdiff
+#compdef co ci rcs rcsdiff merge
 
 local ret=1
 
-if [[ -d RCS && $service != ci ]]; then
+if [[ $service = merge ]]; then
+  _arguments \
+    '-E[output unmerged changes, bracketing conflicts]' \
+    '-A[output conflicts using the -A style of diff3]' \
+    '-e[output unmerged changes]' \
+    '*-L[specify labels for corresponding files]' \
+    '-p[send results to standard output]' \
+    '-q[do not warn about conflicts (quiet)]' \
+    '-V[display version information]' \
+    '1:file:_files' \
+    '2:original file:_files' \
+    '3:modified file:_files' && ret=0
+elif [[ -d RCS && $service != ci ]]; then
   local rep expl
 
   rep=(RCS/*,v(D:t:s/\,v//))
Index: Completion/Unix/Command/_wiggle
===================================================================
RCS file: Completion/Unix/Command/_wiggle
diff -N Completion/Unix/Command/_wiggle
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Completion/Unix/Command/_wiggle	1 Mar 2004 11:46:06 -0000
@@ -0,0 +1,23 @@
+#compdef wiggle
+
+local fns='-m --merge -d --diff -x --extract'
+
+_arguments \
+  "($fns -1 -2 -3)"{-m,--merge}'[select the merge function]' \
+  "($fns -3 3)"{-d,--diff}'[display differences between files]' \
+  "($fns 2 3)"{-x,--extract}'[extract one branch of a patch or merge file]' \
+  '(-w --words -l --lines)'{-w,--words}'[make operations and display word based]' \
+  '(-l --lines -w --words)'{-l,--lines}'[make operations and display line based]' \
+  '(-p --patch)'{-p,--patch}'[treat last named file as a patch]' \
+  '(-r --replace)'{-r,--replace}'[replace orginal file with merged output]' \
+  '(-R --reverse -x --extract)'{-R,--reverse}'[swap the files or revert changes]' \
+  '(-2 -3 -m --merge)-1[select branch]' \
+  '(-1 -3 -m --merge)-2[select branch]' \
+  '(-1 -2 -m --merge)-3[select branch]' \
+  '(1 2 3 -)'{-h,--help}'[display help information]' \
+  '(1 2 3 -)'{-V,--version}'[display version information]' \
+  '(-v --verbose -q --quiet)'{-v,--verbose}'[enable verbose output]' \
+  '(-q --quiet -v --verbose)'{-q,--quiet}'[enable quiet output]' \
+  '1:file:_files' \
+  '2:file:_files' \
+  '3:file:_files'



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