Adding Custom Scripts to Your PATH in Bash

Recently, I found myself repeatedly typing full paths just to run my own scripts. That got old quickly.
I wanted a way to call my personal Bash scripts from anywhere in the terminal without navigating to ~/scripts
every time. The fix? Just add the folder to my $PATH
.
Here’s the line I added to my ~/.bashrc
:
export PATH="$PATH:/home/roy/scripts" # include my scripts folder in $PATH so can call from anywhere
Why I Did It
I’ve been building small utility scripts, things like automation, text parsing, and network checks, and I wanted them globally accessible just like regular commands (ls
, ping
, etc.).
Typing ~/scripts/
myscript.sh
every time was both slow and ugly. I wanted to be able to just run:
myscript.sh
from any directory in the terminal.
How It Works
The PATH
environment variable tells your shell where to look for executable files. When you type a command, Bash checks each directory in $PATH
(in order) to find the matching executable.
By appending :/home/roy/scripts
to the existing $PATH
, I’m telling Bash: “Hey, also check this folder when looking for commands.”
Adding it to ~/.bashrc
ensures it gets applied every time I start a new terminal session.
Don't Forget
After editing ~/.bashrc
, make sure to reload it with:
source ~/.bashrc
And your scripts need to be marked as executable:
chmod +x ~/scripts/myscript.sh
Final Result
Now I can just run myscript.sh
from anywhere in my terminal. Faster, and way less typing.
Subscribe to my newsletter
Read articles from Roy Hayden directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
