MacOS – OS X – Create a personal bin directory (~/bin) and run scripts without specifying their full path

bashmacosterminal

So, what I am trying to do is to create a personal bin directory at my home folder. I created the following folder:

/Users/thi/bin

I put my scripts in this folder, but if I type in the Terminal:

myScript

It doesn't run.

I was told I have to export this bin path, something related to echo $PATH, but I don't know how to do it.

Best Answer

You need to add the following to file ~/.profile:

export PATH=/Users/thi/bin:$PATH

Then source ~/.profile

Note, that you may need to create this file, and because it begins with a . it might not be visible in the finder for editing via an application like a text editor. To list all files including hidden ones, use:

ls -la ~/