about summary refs log tree commit diff
path: root/Completion/Unix/Command/_diff3
blob: 81e274d051f02c745fe19d11ade8afb7beea2802 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#compdef diff3

local -a args ed
local ign

if _pick_variant gnu=GNU unix; then
  ed=(
    '(-m --merge -A --show-all)'{-e,--ed}'[output ed script for incorporating changes]'
    '(-m --merge -A --show-all)'{-E,--show-overlap}'[like -e, but bracket conflicts]'
    '(-m --merge -A --show-all)'{-3,--easy-only}'[like -e, but incorporate only nonoverlapping changes]'
    '(-m --merge -A --show-all)'{-x,--overlap-only}'[like -e, but incorporate only overlapping changes]'
    '(-m --merge -A --show-all)-X[like -x, but bracket conflicts]'
  )
  (( $#words > 2 )) && ign='!'
  args=(
    '(-A --show-all ed)'{-A,--show-all}'[output all changes, bracketing conflicts]'
    "(-m --merge)-i[append 'w' and 'q' commands to ed scripts]"
    '(-m --merge -i ed)'{-m,--merge}'[output merged file instead of ed script]'
    '(-a --text)'{-a,--text}'[treat all files as text]'
    '--strip-trailing-cr[strip trailing carriage return on input]'
    '(-T --initial-tab)'{-T,--initial-tab}'[make tabs line up by prepending a tab]'
    '--diff-program=[specify program to compare files]: : _command_names -e'
    \*{-L+,--label=}'[use specified label instead of file name]:label'
    "$ign(-)--help[display usage information]"
    "$ign(-)"{-v,--version}'[display version information]'
  )
else
  args=( -A "-*" )
  ed=(
    '-e[output ed script for incorporating changes]'
    '-E[like -e, but bracket conflicts]'
    '-x[like -e, but incorporate only overlapping changes]'
    '-X[like -x, but bracket conflicts]'
    '-3[like -e, but incorporate only nonoverlapping changes]'
  )
  if [[ $OSTYPE != solaris* ]]; then # likely the openbsd diff3 implementation
    args+=( '-a[treat all files as text]' )
  fi
fi

_arguments -s -S $args \
  '1:updated file:_files' \
  '2:original file:_files' \
  '3:updated file:_files' \
  + '(ed)' $ed