I’ve been writing a few bash scripts and some Nim command line utilities.

You can run a script from the folder which contains the script. Here’s an example file structure:

~/bin/
├── git-reset-author.sh
└── readme_template

When I’m inside the ~/bin directory, I can type into the terminal: readme_template.

But what if I want to navigate to a different folder on my machine and run the script from that location?

fish: unknown command readme_template

The shell doesn’t find the program.

You can add the folder with your scripts to your user path.

For Bash:

export PATH="$HOME/bin:$PATH"

You have to add it to your [shell configuration][linuxizes], e.g. ~/.bashrc if you want to have it work across reboots.

For Fish: Fish has a variable called fish_user_paths to which you can prepend the folder with your scripts:

set -U fish_user_paths $HOME/bin $fish_user_paths

Further Reading