about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <okiddle@yahoo.co.uk>2018-08-24 07:55:08 +0200
committerOliver Kiddle <okiddle@yahoo.co.uk>2018-08-24 08:04:12 +0200
commitf7deb4951387a239500853b43464aad820131235 (patch)
treef3ea142211e3a4a6b6cb68b88fe4751f6b4efefb
parentf4a1c3c4a34f9a7d2572be5a8811576566fc3ebf (diff)
downloadzsh-f7deb4951387a239500853b43464aad820131235.tar.gz
zsh-f7deb4951387a239500853b43464aad820131235.tar.xz
zsh-f7deb4951387a239500853b43464aad820131235.zip
43329: new diff3 completion
-rw-r--r--ChangeLog2
-rw-r--r--Completion/Unix/Command/_diff346
2 files changed, 48 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 9f4933c9f..12d67c6d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2018-08-24  Oliver Kiddle  <okiddle@yahoo.co.uk>
 
+	* x: Completion/Unix/Command/_diff3: new diff3 completion
+
 	* 43328: Completion/X/Command/_zeal: new completion
 
 2018-08-23  dana  <dana@dana.is>
diff --git a/Completion/Unix/Command/_diff3 b/Completion/Unix/Command/_diff3
new file mode 100644
index 000000000..81e274d05
--- /dev/null
+++ b/Completion/Unix/Command/_diff3
@@ -0,0 +1,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
+