Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've just created my first Command Line Tool in Xcode.

What do I have to do, or where do I have to put the final output file, so that I can run it from anywhere from within terminal, without having to go to the directory the actual Unix Executable File is in.

An example of this is the Java and Git executables, which I can run in the terminal regardless of the location I'm in.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can add the location into your executable path.

Step 1: Use an editor to open ~/.profile

Step 2: Add the actual path into the file. For example, I added /Users/work/documents/fun/scripts into it and my ~/.profile looks like

export PATH=/usr/local/sbin:/opt/local/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/Users/work/documents/fun/scripts:$PATH

Step 3: Restart terminal, and issue which command. You should see the path of your program, and should be able to run the program regardless of your location.

which git
=> /usr/bin/git

Or another way, move the program into the existing executable path. To see existing executable path.

echo $PATH
share|improve this answer
    
+1 thanks! do you if xcode can build a package that does this automagically? –  andy Jun 17 '12 at 3:01
    
It should be possible, Xcode can run script during build and you can probably do a script that does this. But I have not tried it myself. –  revolver Jun 17 '12 at 4:21
1  
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.