Fish shell: Customize $PATH

nabbisen

nabbisen

Posted on May 12, 2021

Fish shell: Customize $PATH

Summary

This post shows how to customize $PATH, an environment variable, in Fish shell.

How-to

Here shows how to add to $PATH, for example.

1. Set Temporarily

All what to do is run this command:

$ set -x PATH <some-path> $PATH
Enter fullscreen mode Exit fullscreen mode

Well, set's -x (or --export) means it "causes the specified shell variable to be exported to child processes (making it an "environment variable")".

2. Set Permanently

2-1. config.fish

Fish shell has $HOME/.config/fish/config.fish as .profile to other shells. Append this line to the bottom of it:

  ...
+ set PATH <some-path> $PATH
Enter fullscreen mode Exit fullscreen mode

2-2. fish_user_paths

There is another and more "fisher" way. Use its fish_user_paths, a universal variable of Fish shell.
Open your terminal and run this command:

$ set -U fish_user_paths <some-path> $fish_user_paths
Enter fullscreen mode Exit fullscreen mode

-U (or --universal) means it "causes the specified shell variable to be given a universal scope".

Be careful not to write it in config.fish, which is called every time Fish shell starts.

💖 💪 🙅 🚩
nabbisen
nabbisen

Posted on May 12, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Fish shell: Customize $PATH
fish Fish shell: Customize $PATH

May 12, 2021