To add a directory to your PATH, you can follow these steps:
-
Open your terminal.
-
Determine the directory you want to add. For example, let's say you want to add
~/my_scripts. -
Edit your shell configuration file. If you are using
zsh, you would typically edit~/.zshrc. You can open it with a text editor, likenano:nano ~/.zshrc -
Add the following line at the end of the file:
export PATH="$HOME/my_scripts:$PATH"This line adds
~/my_scriptsto the beginning of your PATH. -
Save the file and exit the editor. In
nano, you can do this by pressingCtrl + O, thenEnter, andCtrl + Xto exit. -
Apply the changes by running:
source ~/.zshrc -
Verify that the directory has been added to your PATH:
echo $PATH
You should see your new directory listed in the output. Now you can run scripts or executables located in that directory from anywhere in the terminal.
