Fish shell - Load environment variables from file
In many places, you can find environment files, with the following structure:
1 | FOO1=BAR1 |
When you try to evaluate, this file using source
command, you get an error with the fish shell.
1 | $ source web.env |
This is very annoying, so I’ve decided to write a function that can read this file and load those variables. Here is how you can use it:
1 | $ posix-source web.env |
The source code of this function. Enjoy:
1 | $ cat .config/fish/functions/posix-source.fish |
Photo credits: Banner, Thumbnail