There is a small helper application embedded in the P4Merge application that enables running P4Merge from the OS X command line. We refer to this helper application (launchp4merge) as a "shim".
The shim is a part of the P4Merge application bundle and should not be removed or renamed. To use the shim you must write a small shell script.
Using a text editor, create a file called mymerge.sh containing the following two lines:
<path to P4Merge>/p4merge.app/Contents/Resources/launchp4merge $*
Replace <path to P4Merge> with the real path to the P4Merge application. If you placed P4Merge in the standard Applications directory, the script will look like this:
To use the script, you must make it executable. Enter the command:
chmod +x mymerge.sh
- Place mymerge.sh into the /usr/bin directory (or any directory set in your $PATH environment variable).
After these steps are completed, you can run launchp4merge from the command line. For example, to diff two files, enter the command:
mymerge.sh /path/file_1 /path/file_2
You can pass command line options to launchp4merge as well. To see a list of options, enter mymerge.sh -h and a listing of launchp4merge command options is displayed in the Terminal window.
You can start as many shim processes as you require. Each launchp4merge process is attached to the resulting window in the P4Merge application. When the window is closed, the process terminates automatically.
To use a third-party diff/merge application, you would use an approach similar to the above example. For example, to use "kdiff" as your diff utility, you would create a file called kdiff.sh containing the following lines:
exec /Applications/kdiff3.app/Contents/MacOS/kdiff3 "$1" "$2"
Then proceed with steps 2 and 3 as in the first example, substituting kdiff.sh as the filename.
An alternative to using shell script is to add an "alias" to the shell profile. For example, for the bash shell add the following line to the .bashrc file in the home directory:
Now running p4merge against to relative files in the current working directory will work in the form of:
p4merge file1 file2