OK, so you’ve got some useful tools you’ve written (or simply forked from github.com). How best to make them useable from the Terminal? One way or another, you’ve got to get them into the PATH. If you have sudo privileges and the tool has a installation script (or an install target in its Makefile), you can install it system wide. If there is no install script but you have sudo privileges, you may be able to hack it into /usr/local/bin. But what if you don’t have sudo privileges?
First, you have control over your own PATH, the environment variable that controls the directories that will be searched for commands by the shell. To override the default PATH, edit the file ~/.bashrc. If you aren’t using bash as your shell (why?), look up the documentation of your shell to figure out how to set its PATH.
OK, but you probably don’t want to do this every time you add a new tool. If the tool supports begin run via a symbolic link or can be easily copied, I suggest creating your own personal ~/bin directory:
Next, edit ~/.bashrc and search for a line that begins with export PATH=. If found, replace “PATH=path” with “PATH=~/bin:path“. Otherwise, add the line:
Restart the terminal or run “source ~/.bashrc”, and you will be able to run any tools that you copy or symbolically link to ~/bin.
Not all tools take kindly to being run via a symbolic link or via a copy of the tool. You may need to link or copy additional files or directories (libraries or data files) to your bin directory to get a tool to work. Compiled programs that use dynamically linked libraries (AKA .so files) may require those files be added to the LD_LIBRARY_PATH. If so, you can create a ~/lib directory and add it to the LD_LIBRARY_PATH, just like you added ~/bin to PATH.