Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I specify PATH env var in fish shell in a declarative command

I want my $PATH environment variable to specifically contain 3 specific directories and nothing else.

I don’t want to use individual ADD and REMOVE commands to shape my $PATH variable.

In Bash I can just say PATH="aaa:bbb:ccc"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

But I haven’t found a way to do that in fish shell. OR I’m missing some syntax.

The Fish tutorial also doesn’t cover this. It only mentions iterative approaches (add/remove from path)

What command can I add to my ~/.config/fish/config.fish to accomplish this?

>Solution :

You can use the set with the -gx together because it is a shorthand to define a global variable and export it to the environment in a single command, so for example you can save it into this path ~/.config/fish/config.fish

set -gx PATH /path/to/test1 /path/to/test2 /path/to/test3

don’t forget to restart your shell or run source ~/.config/fish/config.fish for the changes to take effect!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading