Xcode Script Menu and P4

Here is another way that I am able to check out a file using the Xcode Script Menu and a keyboard hot key:

#!/bin/sh
# This shell script checks out the current file from Perforce

# Get the file's path components
FULL_FILE_PATH="%%%{PBXFilePath}%%%"
SRC_FILE=${FULL_FILE_PATH##*/}
FILE_PATH=${FULL_FILE_PATH%/*}

# This line brings in my settings so that Perforce knows what server I am connecting to
# This also assumes that the root of my project has a perforce.rc file
source ~/.bash_login

if [ -f $FULL_FILE_PATH ]
then
	cd $FILE_PATH
	/usr/local/bin/p4 edit $FILENAME
fi

The “Output:” and “Errors:” options were set to “Display in Alert”, not that this is actually applicable here, but that’s how I have it set up.

And here is what my .bash_login file looks like:

# Perforce settings                                                                                                                         
export P4CONFIG=perforce.rc
export P4PORT=mysuperawesomedomain.com:1666
export P4USER=jaimerios
export P4EDITOR=emacs
export P4PASSWD=haaaahahahaHahaHAA!

Oh, and if you want a good starter for how to work with the Script Menu scripts in Xcode, check out this site: http://www.mactech.com

Leave a Reply

Your email address will not be published. Required fields are marked *