Make git-mergetool prefer meld under GNOME, and kdiff3 under KDE. When
considering emerge and vimdiff, check $VISUAL and $EDITOR to see which the
user might prefer.
Signed-off-by: Josh Triplett <redacted>
---
Arguably, kdiff3 should now move down next to meld, below the other
non-graphical tools, so that if the user doesn't run KDE or GNOME they get a
non-KDE, non-GNOME tool. This patch doesn't do that, though.
git-mergetool.sh | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/git-mergetool.sh b/git-mergetool.sh
index bb21b03..2053d43 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -304,7 +304,13 @@ if test -z "$merge_tool"; then
fi
if test -z "$merge_tool" ; then
- if type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
+ # Try tools that match the user's desktop environment
+ if test x"$KDE_FULL_SESSION" = x"true" && type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
+ merge_tool="kdiff3";
+ elif test x"$GNOME_DESKTOP_SESSION_ID" != x"" && type meld >/dev/null 2>&1 && test -n "$DISPLAY"; then
+ merge_tool=meld
+ # Try any graphical tool
+ elif type kdiff3 >/dev/null 2>&1 && test -n "$DISPLAY"; then
merge_tool="kdiff3";
elif type tkdiff >/dev/null 2>&1 && test -n "$DISPLAY"; then
merge_tool=tkdiff@@ -312,6 +318,12 @@ if test -z "$merge_tool" ; then
merge_tool=xxdiff
elif type meld >/dev/null 2>&1 && test -n "$DISPLAY"; then
merge_tool=meld
+ # Try tools specific to the user's editor
+ elif echo "${VISUAL:-$EDITOR}" | grep '^emacs' > /dev/null 2>&1 && type emacs >/dev/null 2>&1; then
+ merge_tool=emerge
+ elif echo "${VISUAL:-$EDITOR}" | grep '^vim' > /dev/null 2>&1 && type vimdiff >/dev/null 2>&1; then
+ merge_tool=vimdiff
+ # Try other tools
elif type opendiff >/dev/null 2>&1; then
merge_tool=opendiff
elif type emacs >/dev/null 2>&1; then--
1.5.2.1