Add bash script folder to path?

Yes, you can add any directory to the system path. One way to do this is updating the PATH (environmental variable) definition. You can do this in your .bashrc by adding the following lines:

PATH="/your/script/dir:${PATH}"
export PATH

I like to add my scripts to $HOME/.local/bin/ (which is a hidden directory) so my home dir stays cleaner.

Your directory will not get inserted into the PATH variable right away, unless you run source .bashrc.

You can add multiple directories to the path, remember that. Please consult BASH documentation if you do not understand the code.

The previous method will only work for your user. If you need to add a script directory for all users do as bodhi.zazen and add your scripts to /usr/local/bin.


IMO the best method is to add the scripts to ~/bin

mkdir ~/bin

~/bin should automatically be added to your path. If not, add this to ~/.bashrc

if [ -d $HOME/bin ]; then
    PATH=$PATH:$HOME/bin
fi

If you want them to be available for all users, add them to /usr/local/bin


another solution

  1. Add path to ~/.bashrc open using vim $ vim ~/.bashrc

    example:

    # add extra paths export PATH=$PATH:~/Scripts

  2. once path is added run:

    $ source ~/.bashrc

  3. If added correctly there should be no errors.