Add a bash script (directory) to your terminal PATH
Edit the ~/.bashrc
file to export
the PATH
with the directory containing your script(s). This will modify every terminal you open with the new path, exposing sripts in the directory you added.
We'll add a line to your .bashrc
that exports your script directory to the path. Something like:
export PATH="~/your/path/to/bash_scripts/:$PATH"
WARNING: :$PATH
at the end is very important. Without it, you won't have access to the built-in scripts. If that happens, just navigate to your current user's home directory in the file manager, show hidden files, and edit .bashrc
by hand.
Append to ~/.bashrc with echo
Edit the APPEND_PATH
below (just click & type), then copy (ctrl+a, ctrl+c
) & paste (ctrl+shift+V
) into your terminal & enter
APPEND_PATH="~/your/path/to/bash_scripts/" # Because variables are cool
echo "export PATH=\"${APPEND_PATH}:\$PATH\"" >> ~/.bashrc
tail -n 2 ~/.bashrc # print the last two lines to verify it was added successfully
# If it's wrong, delete the last line & tail again, with:
# sed '$d' ~/.bashrc > ~/.bashrc.tmp && mv ~/.bashrc.tmp ~/.bashrc; tail -n 2 ~/.bashrc;
Or Use nano... so many keystrokes
nano ~/.bashrc
# arrow key down to the bottom
# type
export PATH="~/your/path/to/bash_scripts/:$PATH"
# Press ctrl+X
# press 'Y' to save (or 'N' to cancel)
# Press Enter (saves to same file name)