I just wanted to be able to add inside some fish configuration file (don't know which/where) the same function as this:

export PERL5LIB=/home/iaco/workspace/perl:/home/iaco/devtools

This line was added inside the .bashrc file and it was able to export the variable each time I opened a terminal.

Is there something like that for fish? I know that I can export variables in fish using the "set" command, but I want to modify one file (don't know which one) in order to automatically add those variables each time I open a fish terminal.

2 Answers 2


You can put the user-specific fish configuration, including set directives, in ~/.config/fish/config.fish. The contents should look more or less like that

set -x PERL5LIB /home/iaco/workspace/perl:/home/iaco/devtools

More information can be found in the documentation.

  • Thanks Adam. The main purpose of this change is to be able to include inside the Perl @inc the path of my local libraries. After added the line you suggested, the export was properly made! But, if I run perl -V I won't see the new paths. I know that this is more a Perl question than a fish one, but I just wanted to know if you (or somebody else) have an idea
    – user13748
    Apr 6, 2011 at 23:38
  • I should've mentioned the -x flag. I've just updated the answer, and you can read more about that in the section "Exporting variables" in the documentation. Apr 7, 2011 at 16:58
  • 1
    The main fish site is down, but the documentation from the fishfish fork is at ridiculousfish.com/shell/user_doc/html/commands.html#set (I assume it's the same). Sep 14, 2012 at 11:43
  • Does fish have access to environmental variables like $PATH?
    – grant
    Jun 27, 2014 at 2:45
  • @grant yes, $PATH etc can be used in fish, including in config.fish. Jun 23, 2019 at 12:39

Use universal variables introduced in fish 2.0.0. -x means exported, and -U means that it's declared for every fish session. You can also use the long options --export and --universal.

set -xU PERL5LIB /home/iaco/workspace/perl:/home/iaco/devtools

Please note that PATH variable is a bit of a special case. While PATH can be universally changed, this will affect your current PATH variable (which may be a bit of a problem if an extra path will be introduced by an operating system). For PATH variable, use fish_user_paths variable (which only adds paths) instead. The variable is an array, which means you don't have to put : characters.

set -U fish_user_paths /home/iaco/workspace/perl/share/bin /home/iaco/bin $fish_user_paths

You must log in to answer this question.