Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Last active August 29, 2022 09:57
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonOfRa/569b7b04cb280c07853fee8363e0782f to your computer and use it in GitHub Desktop.
Save sonOfRa/569b7b04cb280c07853fee8363e0782f to your computer and use it in GitHub Desktop.
Use Sublime Merge as a git mergetool
#!/bin/bash
# A wrapper script to make sublime_merge work more nicely
# when used as a git-mergetool
WORKDIR=`git rev-parse --show-toplevel`
REAL_HOME="$HOME/"
# Replace a leading homedir with ~/ to match the window title
REAL_WORKDIR=${WORKDIR/"^$REAL_HOME"/"~/"}
sublime_merge $REAL_WORKDIR
# Wait here for safety, no idea how long launching
# and daemonizing can take
sleep 2
# List all the windows first
# Then look for all Sublime Merge windows
# Then check if there is one for our current work dir
while wmctrl -lx | grep "sublime_merge.Sublime_merge" | grep -q "$REAL_WORKDIR"; do sleep 1; done
exit 0
[merge]
tool = sublime_merge
[mergetool]
keepBackup = false
[mergetool "sublime_merge"]
trustExitCode = false
cmd = "/path/to/mergetoolwrapper.sh"
@michaelblyons
Copy link

Note that smerge itself is beginning to become a git mergetool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment