I want to prepend a couple directories to the $PATH variable temporarily so that I can set up a temporary development environment that I don't really want to change what other fish sessions see.

So I want to have a setup-env.fish script that prepends the proper paths to the beginning of $PATH so that they take precedence.

My simple test is

set -gx tool_dir "/home/jesse/sandbox/tools"
set PATH "$tool_dir/language/bin" $PATH
echo "Evnironment Set up"

I have made sure that those directories exist. When I open a shell and run that script, if I then echo $PATH that directory does not show up.

I understand that there is a way to persistently add a directory to set -U fish_user_paths path $fish_user_paths that then prepends to the global $PATH variable. But I don't want that. If I want to mess around with some different tools, I don't want to much up my system variables. I'd rather just prepend to $PATH and close the shell if I want. I've read through some of the fish documentation and some github issues about altering $PATH and I gather there are some variables that are treated differently by fish so I just wasn't sure if I am missing something else here.

If I run those commands in the shell it works, but I want my script to do more and I don't want to type in everything in it.

I am using fish 2.7.1 on XUbuntu 16.04.

  • You might want to flag a moderator to request moving this question to Stackoverflow where more fish experts hang out. Mar 8, 2018 at 16:11

2 Answers 2


I think you can change the scope of the fish_user_paths in the current shell only: I believe when you exit this fish session, the universal value of that variable will be unaffected.

set -g fish_user_paths "$tool_dir/language/bin" $fish_user_paths
  • Thanks Glenn, that didn't work when I ran the script but my original script worked when I used source, which I wasn't doing before.
    – Jesse
    Mar 8, 2018 at 17:02

Turns out I had to source the script instead of just running it and then it works the way I wanted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.