Skip to content

Instantly share code, notes, and snippets.

@teopeurt
Last active May 12, 2019 16:53
Show Gist options
  • Save teopeurt/79fd7669168243ca585ff42497a6405f to your computer and use it in GitHub Desktop.
Save teopeurt/79fd7669168243ca585ff42497a6405f to your computer and use it in GitHub Desktop.
command line for p4merge usage.
#!/bin/bash
# chmod +x and copy to ~/bin/p4merge
# then
# git config --global merge.tool p4merge
# git config --global mergetool.keepTemporaries false
# git config --global mergetool.prompt false
if [ -n "$GIT_DIR" ]; then
if $(git submodule | grep -q $2); then
tmp=$(mktemp -t $2) && trap 'rm -rf $tmp' EXIT HUP INT QUIT TERM
sha=$(cd $2 > /dev/null && git rev-parse HEAD)
echo "Subproject commit $sha" > $tmp
set -- $1 $tmp
fi
fi
for arg; do [[ $arg = /* ]] || arg=$PWD/$arg; absargs+=("$arg"); done;
/Applications/p4merge.app/Contents/Resources/launchp4merge "${absargs[@]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment