How to add directory to PATH?

To add a directory to your PATH, you can follow these steps:

  1. Open your terminal.

  2. Determine the directory you want to add. For example, let's say you want to add ~/my_scripts.

  3. Edit your shell configuration file. If you are using zsh, you would typically edit ~/.zshrc. You can open it with a text editor, like nano:

    nano ~/.zshrc
  4. Add the following line at the end of the file:

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

    This line adds ~/my_scripts to the beginning of your PATH.

  5. Save the file and exit the editor. In nano, you can do this by pressing Ctrl + O, then Enter, and Ctrl + X to exit.

  6. Apply the changes by running:

    source ~/.zshrc
  7. 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.

0 Comments

no data
Be the first to share your comment!