Yet another path question

path

I created a Ruby file called Player.rb in the following path:
Jwan/studio_game

Jwan is my name so I think Jwan is my user file.

How do I permanently add the path to the terminal so I don't have to type in pwd and cd commands everytime I open the terminal?

Also, what does the code below do. I tried finding the answer myself but I do not understand what the code below does. What parts of the code below do I replace?

export PATH=/users/ophir/android-sdks/tools:$PATH

Best Answer

First of all I'd confirm that path. I believe the full path might be "/User/Jwan/studio_game". Type ls -al /User/Jwan/studio_game into a Terminal window and see if it lists your file.

Assuming that works, then within the Terminal you could use the following command to add that location to your PATH variable. Then open a new Terminal window (or a new tab within the existing one) and the change should have taken effect.

echo export PATH='/User/Jwan/studio_game:$PATH' >> ~/.bash_profile

And just to explain that command...

  • echo says to write whatever follows to standard output.
  • export says you want to export a variable.
  • PATH is the name of the variable you want to export.
  • $PATH refers to the existing variable.
  • >> redirects standard output to a file. >> appends to the file if it exists, or creates it if it doesn't. > on its own would replace the file if it already existed.
  • ~ represents your home folder which I assume is /Users/Jwan.
  • .bash_profile is a file that is loaded whenever you open a new Bash session that can be used to run various commands to set up variables the most common being the PATH variable.