You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was some discussion of removing the universal variable functionality in #7317. Some good initial ideas were brought up there.
Reacted by Firegem, Patrick Fong, Debashis Biswas, Mészáros Máté Róbert, Wuelner Martínez, Garrett, Techcable, Lucas Pütz, MrDowntempo, John Lyon-Smith and 15 more
Reacted by Aaron Gyes, Yaksh Bariya, soue, Caleb Goetsch and Mat
Loading universal variables from fish_variables is currently much faster than specifying them as globals in your config.fish. See also my proposal #7432
Reacted by CK, Aaron Gyes, Eugene Oliveros, Ertug and Isaac de Andrade
@planet36 That is why the issue is called "Remove universal variables", yes. It means that we would like to remove universal variables, in their current form.
They would be replaced with something that doesn't have their drawbacks, see #7317 (comment).
Fish can't reconstruct lists from variables it imports (unix doesn't know lists, so it collapses down to one string)
You're using "is-login" uselessly
Really, if you just want to "set a variable", you should probably do that in all shells, or at least interactive ones. There is no need to only do it sometimes, in some shells that your environment gets to specifically pick.
You're also missing a --global - "exported" is not a scope.
One issue using a universal variable here can cause is that it makes overriding it sometimes awkward. Say you want to pick different CXXFLAGS for a thing. So you go there in your shell, set CXXFLAGS --my-cool-flag. You want to quickly check something, so you open another shell and run a few commands there, you close it and go back to your old shell. You had set the variable, right? Well, yeah, and then your config set it back!
(@krobelus this is also why I'm against merging universal and global scopes, btw)
uvars are often misunderstood by users (resulting in huge $PATH variables).
We are trying to replace them with something simpler that keeps the good features.
IOW,
Reacted by David Judge, Chen Guixin and Jacob Chapman
I had just noticed the documentation has been changed to encourage folks to make config files with set -g commands, generally discouraging set -U, references touting uvars as a feature have been removed, and I noticed #7379Remove universal variables (this is it) and #7317Remove default universal variables, and the issues were left open and milestoned fish-future. A PR was nearly merged that switched all uvars that were set on first launch to globals.
So I thought folks were thinking to do away with universal variables and maybe replace them with some mechanism that just saves/maintains init scripts, honestly.
I thought someone was thinking to do away with universal variables and replace them with some mechanism that just saves maintains an init script, honestly.
I was curious what this might be like, so I decided to create some functions that implement it. I thought I'd share in case anyone else would like to try it out. It works really well, I don't really notice a difference between this and using universal variables.
It does cheat a little and use a universal variable to communicate changes between multiple sessions, but other than this deals only with global variables.
I want to stress this is just my personal take on how this might work. The final implementation could be similar or very different. I'm not working on implementing this.
How to use
Copy the below functions to a new file in ~/.config/fish/conf.d/ or $XDG_CONFIG_HOME/fish/conf.d/ (whichever is appropriate for your system). My suggested filename is persist_variables.fish, but you can name it however you want (but do read the known issues). You should create a new file for this as it will reload from whatever file it is placed in from time to time. Once you've created the file, source it to load it.
Use the persist_variable function to persist variables. It accepts multiple variable names as arguments, so you can add more than one at a time. It also accepts the option -r/--remove-universal to convert a universal variable into a global one in addition to persisting it. If you do not use -r/--remove-universal, the universal variable will be left alone. I recommend using the flag to convert universal variables.
Use the unpersist_variable function to stop a variable from being persisted. It accepts multiple variable names as arguments, so you can stop persisting more than one at a time. It also accepts the option -c/--create-universal to convert the variable into a universal one. Very big note with unpersist_variable: it does not delete/remove variables passed to it. It only stops a variable from being persisted.
Both functions have completions.
Known issues / quirks
The functions below should load after the persist file itself. If the functions load before the persist file is, the event handler will fire for every variable in the persist file as it is loaded, which will have the event handler recreating the persist file multiple times. This will not cause issues, but will create unnecessary file IO. The persist file is saved to ~/.config/fish/conf.d/0000-persist.fish or $XDG_CONFIG_HOME/fish/conf.d/0000-persist.fish, so as long as whatever you name the file the persist functions are in something that will not load before that, it will be fine.
If you delete/remove a variable (set -e somevar), the variable will be removed from all sessions, but it will still be considered persisted. If at some point later you do set -g somevar someval, it will be persisted again. If you want a value to be both removed and not persisted, first do set -e somevar and then unpersist_variable somevar.
If you have a persisted variable that can change in an automated way (with an event handler, for instance), this will cause all sessions to update the persist file. This will not cause problems, but can create a lot of file IO.
The -c/--create-universal option of unpersist_variable removes the global variable, and then one second later creates the universal variable. This is done to avoid multiple sessions from writing the persist file when the universal variable is created. It does mean that for one second, the variable does not exist.
If you create a local variable or universal variable with the same name as a variable that is persisted, the event handler will fire and update the persist file. However, the event handler cannot see the value of the local/universal variable, so uses the value of the global one.
There are variables that have been set to not be persisted. Most of these are read only variables, but there are a few, like PATH, that I've added because they could cause fish or things running to break or be unpredictable.
If anyone runs into an issue using this, do please let me know.
$\textsf{\color{blue}{persist\_variables.fish}}$
ifset-gxq __persist_no_load
returnendifnotset-gq __persisted_variables
set-g __persisted_variables
endifnotset-Uq __persisted_var_notifier
set-U __persisted_var_notifier $fish_pidendset-l __persist_file $__fish_config_dir/conf.d/0000-persist.fish
ifnotfunctions-q __update_persisted
set-l __no_persist _ __fish_bin_dir __fish_cache_dir __fish_cd_direction __fish_config_dir \
__fish_data_dir __fish_help_dir __fish_initialized __fish_man_dir __fish_sysconf_dir \
__fish_uname __fish_vendor_completionsdirs __fish_vendor_confdirs __fish_vendor_functionsdirs \
__persist_file __persisted_variables __persisted_var_notifier CMD_DURATION COLUMNS dirnext \
dirprev EUID fish_complete_path fish_features fish_function_path fish_kill_signal \
fish_killring fish_pid fish_terminal_color_theme FISH_VERSION history HOME hostname IFS \
LINES PATH pipestatus PWD SHLVL status status_generation TERM USER version
function __update_persisted --inherit-variable __persist_file \--inherit-variable __no_persist \--on-variable __persisted_variables
ifset-q __persisted_variables
for i in$__no_persist
ifcontains -- $i$__persisted_variables
set-l idx (contains-i -- $i$__persisted_variables)
set-e __persisted_variables[$idx]
echo"$(set_color $fish_color_error)Will not persist '$i'$(set_color normal)">&2endend
source (status filename) # We need to rebuild the persist function
__persist_variables
elseecho"`persisted_variables` variable was erased. In case this was an accident,"echo"this is not being persisted (otherwise $(set_color -i)all persisted variables"\"would be removed$(set_color normal))."echoecho"If it was an accident, type $(echo "source $__persist_file" | fish_indent --ansi) to restore it"echo"If you do wish to remove all persisted variables, type"\
(echo"set -g __persisted_variables"| fish_indent --ansi)
endendfunction __persist_tmp_file -a filename
set-l tmp_file (__fish_mktemp_relative $filename)
ifnot string length -q -- $tmp_fileset-l tmpdir (path filter -d-r-w$TMPDIR /tmp)
ifset-q tmpdir[1]
set tmp_file $tmpdir[1]/$filename-$fish_pid.fish
elseset tmp_file $__fish_config_dir/$filename-$fish_pid.fish
endendecho$tmp_fileendfunction persist_variable --inherit-variable __no_persist --description"Adds variables to be persisted"ifnot string length -q -- $argvreturnend
argparse --name=persist_variable r/remove-universal -- $argv||return 1
set-l np $__persisted_variables
set-l added_variable falsefor variable in$argvifnot string match -qr -- "^(?:$(string join -- '|' $__no_persist))\$"$variableifnotcontains -- $variable$__persisted_variables
# If the variable is universal, we create a globalifset-Uq$variableifnotset-gq$variableifset-Uxq$variable&&set-Uq--path$variableset-gx--path--no-event$variable $$variableelseifset-Uxq$variableset-gx--no-event$variable $$variableelseifset-Uq--path$variableset-g--path--no-event$variable $$variableelseset-g--no-event$variable $$variableendendif string length -q -- $_flag_r
set-Ue--no-event$variableendendset added_variable trueset-a np $variableelseecho"Variable '$variable' is already persisted">&2endelseecho"$(set_color $fish_color_error)Will not persist '$variable'$(set_color normal)"endendif$added_variable# This sorts the variablesset __persisted_variables (path sort$np)
endendfunction __persist_completions --inherit-variable __no_persist --description='Completions for persist_variable'set-l vars (set-n| string match -rv -- "^(?:$(string join -- '|' $__no_persist))\$"|\
string match -rv -- '^(?:___|XDG_)'| string match -rv -- "^(?:$(string join -- '|' (set -ln))\$)"|\
string match -rv -- "^(?:$(string join -- '|' $__persisted_variables))\$")
for var in$varsifset-Uq$varprintf'%s\tUniversal\n'$varelseprintf'%s\tGlobal\n'$varendendendcomplete-c persist_variable -f-s r -l remove-universal -d"Remove universal variables"complete-c persist_variable -f-a"(__persist_completions)"function unpersist_variable --description"Stops variables from being persisted"ifnot string length -q -- $argvreturnendset-l removed_variable falseset-l unp $__persisted_variables
argparse --name=unpersist_variable c/create-universal -- $argv||return 1
for variable in$argvset-l idx (contains-i -- $variable$unp)
ifset-q idx[1]
set removed_variable trueset-e unp[$idx]
if string length -q -- $_flag_c
ifnotset-q __persist_to_universal
set-g __persist_to_universal
endifnotset-q __unpersist_file
set-g __unpersist_file (__persist_tmp_file unpersist_variables)
endset-a __persist_to_universal $variable# This is to stop multiple sessions from creating a lot of disk IOifset-xq$variable&&set-q--path$variableecho"set --universal --export --path --no-event $variable"\
(string escape --style=script -- $$variable) >>$__unpersist_file
elseifset-xq$variableecho"set --universal --export --no-event $variable"\
(string escape --style=script -- $$variable) >>$__unpersist_file
elseifset-q--path$variableecho"set --universal --path --no-event $variable"\
(string escape --style=script -- $$variable) >>$__unpersist_file
elseecho"set --universal --no-event $variable"\
(string escape --style=script -- $$variable) >>$__unpersist_file
endset-ge--no-event$variableendelseecho"$(set_color $fish_color_error)$variable is not persisted$(set_color normal)">&2endendif$removed_variableset __persisted_variables $unpendif string length -q -- $__unpersist_file
# Launch another instance of fish to load the universals after one secondset-lx __persist_no_load true
fish -c"sleep 1; source $__unpersist_file && rm $__unpersist_file"&; disown
set-e __unpersist_file
endendfunction __unpersist_completions --description='Completions for unpersist_variable'printf'%s\n'$__persisted_variables
endcomplete-c unpersist_variable -f-s c -l create-universal -d"Create universal variables"complete-c unpersist_variable -f-a"(__unpersist_completions)"function __persisted_variable_notifier --inherit-variable __persist_file --on-variable __persisted_var_notifier
functions-e __persist_variables
source $__persist_file
source (status filename) # Rebuild the __persist_variables functionendendfunctions-q __persist_variables &&functions-e __persist_variables
begin# If persisted_variables is empty, do not listen for any variablesifset-q __persisted_variables[1]
echo"function __persist_variables --on-variable"\
(string join -- ' --on-variable '$__persisted_variables)
elseecho"function __persist_variables"endecho" set -l ____persist_file \$(__persist_tmp_file persist)"echo" echo '# Persisted variables autogenerated by __persist_variables' >\$____persist_file"echo" echo '# DO NOT EDIT THIS FILE, changes can be overwritten' >>\$____persist_file"echo" echo '# Use the persist_variable or unpersist_variable functions instead' >>\$____persist_file"echo" echo >>\$____persist_file"echo" echo \"set --global --no-event __persisted_variables\" (string escape --"\"\$__persisted_variables) >>\$____persist_file"echo" for ____variable in $__persisted_variables"echo" if not set -q \$____variable"echo" echo \"set --global --query \$____variable && set --global --erase"\"\$____variable\" >>\$____persist_file"echo" continue"echo" end"echo" set -l ____path"echo" set -l ____export"echo" if set -xq \$____variable"echo" set ____export --export"echo" end"echo" if set --path -q \$____variable"echo" set ____path --path"echo" end"echo" echo \"set --global\"\$____export \$____path \$____variable"\"(string escape -- \$\$____variable) >>\$____persist_file"echo" end"echo" if set -q __persist_to_universal"echo" # Remove global variables that were unpersisted and set back to universal variables"echo" printf '\n# Removed persisted variables that are now universal variables:\n\n' >>\$____persist_file"echo" for ____variable in \$__persist_to_universal"echo" echo \"set --global --query \$____variable && set --global --erase --no-event"\"\$____variable\" >>\$____persist_file"echo" end"echo" set -e __persist_to_universal"echo" end"echo" if command -q flock"echo" set -lx __persist_no_load true"echo" command flock -x $__persist_file -c \"cat \$____persist_file > $__persist_file\" && rm \$____persist_file"echo" else"echo" cp \$____persist_file $__persist_file && rm \$____persist_file"echo" end"echo" set --no-event __persisted_var_notifier \$(random)"echoendend| source
ifnottest-f$__persist_file
__persist_variables
end
Edit 2026/01/20: Fixed an issue that could cause a hang when launching a sub shell
Managing persistent variables is a good idea. But I think this juggling of state and other things is very cumbersome to implement, maintain, and use.
Persistent variables should be override-able by tools and scripts if they are exported (don't know how that would be achieved in a simple way, though), this way tools can manipulate them as needed. Maybe they could also have a comment on top showing what process last change them to help with debugging, I'm not sure.
In case it's decided that persistent variables will never be exported, all exported ones would be global and set in config.fish or conf.d/ and loaded at shell start up like other shells.
Or... limit exported state to globals only (set --export would imply global scope always) and all universal vars would be manipulated by fish internally and by user in XGD_CONFIG_HOME/.config/fish/persitent.fish and CLI.
Today I was confused for over an hour because I had accidentally gotten a path added to the universal variables file. I had no idea that file existed and don't remember running a command that would have added it. (As a new fish user I probably - against better knowing - ran an interactive fish_add_path command and didn't know the consequences)
What happened: upon startup /bin got added to the start of my path from the universal variable file. This meant that when I activated a nix-environment with nix-shell my_env.nix, I didn't see the binary from my nix configuration, because a new shell was spawned, prepending /bin, shadowing my nix path and effectively making my nix environment un-discoverable.
I would have been better of if the PATH env var setting was not universally saved.
While waiting for universal variables to be removed. Is there any setting or workaround I can do to disable/block universal variables from being added?
I was also confused by this for over an hour trying to remove paths to binaries in a git work tree that were conflicting with the paths to another git work tree. I'm new to fish and probably misused the fish_add_path command as well.
I ended up just deleting the universal PATH variable with set --erase --universal PATH.
I then oscillated between running set -gx PATH and set -gx PATH (string match -v /path/to/unwanted/dir/bin $PATH) and restarting my computer to verify the results with set --show PATH.
If I misunderstood my own problem/solution, or if there's a better way to avoid this foot-gun I'm all ears.
@jon-munoz thanks for sharing. You certainly aren't the first to trip over PATH handling, in any shell.
To be sure, $PATH is not a universal variable. If you try to make it one, you'll get a warning. It's just an ordinary global exported variable, same as any other shell.
If you look in a typical .bashrc or .zshrc you'll probably see a bunch of lines like:
So if you're making a change to PATH that you want to be local to a session - not persistent - you either would modify $PATH directly like you would in zsh (or you can use fish_add_path with the --path option).
The important point is that $PATH works basically the same in fish as in other shells and you can use the same techniques to manage it, if you prefer. It's not universal, and you are free to ignore universal variables entirely if you prefer to manage it manually!
That doesn't get your time back but hopefully it helps clear things up for you or the next reader.
Reacted by charego, Jon S. Muñoz and Isaac de Andrade
Activity
folke commentedon Oct 28, 2020
Loading universal variables from
fish_variablesis currently much faster than specifying them as globals in yourconfig.fish. See also my proposal #7432krobelus commentedon Jun 19, 2021
A lightweight first iteration of this could look like:
This removes support for shadowing of universals with globals, which is probably not used very much[citation needed].
The next obvious step would be to remove the universal scope, since at this point it's just used as flag whether the variable is persisted.
In the end we probably want a different interface for universal variables
planet36 commentedon Jul 29, 2021
Is the universal variable feature going to be removed from fish?
faho commentedon Jul 30, 2021
@planet36 That is why the issue is called "Remove universal variables", yes. It means that we would like to remove universal variables, in their current form.
They would be replaced with something that doesn't have their drawbacks, see #7317 (comment).
planet36 commentedon Jul 31, 2021
Here's a problem I had that I solved using universal variables. (If there's a better way, please let me know.)
In my config.fish I set environment variable
CXXFLAGSin a block like this.The intent is to set my environment variables once upon login, not every invocation of fish.
Using
$CXXFLAGSworks as expected at first.count $CXXFLAGSg++ $CXXFLAGS test.cppsuccess
But when I open a nested shell, the variable expansion (or maybe it's the splitting) is different.
open a nested shell
fishcount $CXXFLAGSg++ $CXXFLAGS test.cppI understand the following work-around, but I'd rather not type it out often.
count (string split -- ' ' $CXXFLAGS)In bash, the environment variable is expanded/split as expected.
open a nested shell
bashg++ $CXXFLAGS test.cppsuccess
When I make
CXXFLAGSboth universal and exported, it always expands as expected, even in nested shells.Repeat the example above and notice that
count $CXXFLAGSprints the same value.Maybe my confusion is a point in favor of removing uvars, idk.
krobelus commentedon Jul 31, 2021
You can remove the
ifand set it as global variable in every new shell.Or keep using the universal one; the replacement should be as powerful.
I would only export it if really necessary.
faho commentedon Jul 31, 2021
@planet36 What is happening here is two things:
Really, if you just want to "set a variable", you should probably do that in all shells, or at least interactive ones. There is no need to only do it sometimes, in some shells that your environment gets to specifically pick.
You're also missing a
--global- "exported" is not a scope.One issue using a universal variable here can cause is that it makes overriding it sometimes awkward. Say you want to pick different CXXFLAGS for a thing. So you go there in your shell,
set CXXFLAGS --my-cool-flag. You want to quickly check something, so you open another shell and run a few commands there, you close it and go back to your old shell. You had set the variable, right? Well, yeah, and then your config set it back!(@krobelus this is also why I'm against merging universal and global scopes, btw)
floam commentedon Nov 5, 2021
I'm not convinced. "I don't use them and here's why" is immaterial.
floam commentedon Nov 5, 2021
Users have never needed a config file with fish. Hell, I haven't either. Universal variables are a fish killer feature.
krobelus commentedon Nov 6, 2021
uvars are often misunderstood by users (resulting in huge $PATH variables).
We are trying to replace them with something simpler that keeps the good features.
IOW,
floam commentedon Nov 6, 2021
🧐 … Well that's reassuring, Mr Ulbricht.
I had just noticed the documentation has been changed to encourage folks to make config files with
set -gcommands, generally discouragingset -U, references touting uvars as a feature have been removed, and I noticed #7379 Remove universal variables (this is it) and #7317 Remove default universal variables, and the issues were left open and milestoned fish-future. A PR was nearly merged that switched all uvars that were set on first launch to globals.So I thought folks were thinking to do away with universal variables and maybe replace them with some mechanism that just saves/maintains init scripts, honestly.
krobelus commentedon Nov 6, 2021
yeah that's a possible solution
floam commentedon Nov 6, 2021
Collapse universal scope into global scope
Collapse universal scope into global scope
perf(fish): make a little bit faster
perf(fish): make a little bit faster
perf(fish): make a little bit faster
Bit0r commentedon Dec 8, 2024
When the user uses
set -U var value, theset -g var valueis automatically written to~/.config/fish/conf.d/universal.fish, how about the idea?Darkshadow2 commentedon Jan 15, 2026
I was curious what this might be like, so I decided to create some functions that implement it. I thought I'd share in case anyone else would like to try it out. It works really well, I don't really notice a difference between this and using universal variables.
It does cheat a little and use a universal variable to communicate changes between multiple sessions, but other than this deals only with global variables.
I want to stress this is just my personal take on how this might work. The final implementation could be similar or very different. I'm not working on implementing this.
How to use
Copy the below functions to a new file in
~/.config/fish/conf.d/or$XDG_CONFIG_HOME/fish/conf.d/(whichever is appropriate for your system). My suggested filename ispersist_variables.fish, but you can name it however you want (but do read the known issues). You should create a new file for this as it will reload from whatever file it is placed in from time to time. Once you've created the file,sourceit to load it.Use the
persist_variablefunction to persist variables. It accepts multiple variable names as arguments, so you can add more than one at a time. It also accepts the option-r/--remove-universalto convert a universal variable into a global one in addition to persisting it. If you do not use-r/--remove-universal, the universal variable will be left alone. I recommend using the flag to convert universal variables.Use the
unpersist_variablefunction to stop a variable from being persisted. It accepts multiple variable names as arguments, so you can stop persisting more than one at a time. It also accepts the option-c/--create-universalto convert the variable into a universal one. Very big note withunpersist_variable: it does not delete/remove variables passed to it. It only stops a variable from being persisted.Both functions have completions.
Known issues / quirks
~/.config/fish/conf.d/0000-persist.fishor$XDG_CONFIG_HOME/fish/conf.d/0000-persist.fish, so as long as whatever you name the file the persist functions are in something that will not load before that, it will be fine.set -e somevar), the variable will be removed from all sessions, but it will still be considered persisted. If at some point later you doset -g somevar someval, it will be persisted again. If you want a value to be both removed and not persisted, first doset -e somevarand thenunpersist_variable somevar.-c/--create-universaloption ofunpersist_variableremoves the global variable, and then one second later creates the universal variable. This is done to avoid multiple sessions from writing the persist file when the universal variable is created. It does mean that for one second, the variable does not exist.PATH, that I've added because they could causefishor things running to break or be unpredictable.If anyone runs into an issue using this, do please let me know.
Edit 2026/01/20: Fixed an issue that could cause a hang when launching a sub shell
andradei commentedon Jan 27, 2026
Managing persistent variables is a good idea. But I think this juggling of state and other things is very cumbersome to implement, maintain, and use.
Persistent variables should be override-able by tools and scripts if they are exported (don't know how that would be achieved in a simple way, though), this way tools can manipulate them as needed. Maybe they could also have a comment on top showing what process last change them to help with debugging, I'm not sure.
In case it's decided that persistent variables will never be exported, all exported ones would be global and set in
config.fishorconf.d/and loaded at shell start up like other shells.andradei commentedon Jan 27, 2026
Or... limit exported state to globals only (
set --exportwould imply global scope always) and all universal vars would be manipulated by fish internally and by user inXGD_CONFIG_HOME/.config/fish/persitent.fishand CLI.refactor(fish): remove all use of universal variables
kaddkaka commentedon Apr 7, 2026
Today I was confused for over an hour because I had accidentally gotten a path added to the universal variables file. I had no idea that file existed and don't remember running a command that would have added it. (As a new fish user I probably - against better knowing - ran an interactive fish_add_path command and didn't know the consequences)
What happened: upon startup
/bingot added to the start of my path from the universal variable file. This meant that when I activated a nix-environment withnix-shell my_env.nix, I didn't see the binary from my nix configuration, because a new shell was spawned, prepending/bin, shadowing my nix path and effectively making my nix environment un-discoverable.I would have been better of if the
PATHenv var setting was not universally saved.While waiting for universal variables to be removed. Is there any setting or workaround I can do to disable/block universal variables from being added?
jon-munoz commentedon Apr 17, 2026
I was also confused by this for over an hour trying to remove paths to binaries in a git work tree that were conflicting with the paths to another git work tree. I'm new to fish and probably misused the
fish_add_pathcommand as well.I ended up just deleting the universal PATH variable with
set --erase --universal PATH.I then oscillated between running
set -gx PATHandset -gx PATH (string match -v /path/to/unwanted/dir/bin $PATH)and restarting my computer to verify the results withset --show PATH.If I misunderstood my own problem/solution, or if there's a better way to avoid this foot-gun I'm all ears.
ridiculousfish commentedon Apr 17, 2026
@jon-munoz thanks for sharing. You certainly aren't the first to trip over PATH handling, in any shell.
To be sure, $PATH is not a universal variable. If you try to make it one, you'll get a warning. It's just an ordinary global exported variable, same as any other shell.
If you look in a typical
.bashrcor.zshrcyou'll probably see a bunch of lines like:This works fine in fish if you prefer to manage your $PATH like that.
What
fish_add_pathdoes is automate this by storing those additional path entries in a universal variable named$fish_user_paths. It's as if you ran in bash:So if you're making a change to PATH that you want to be local to a session - not persistent - you either would modify $PATH directly like you would in zsh (or you can use
fish_add_pathwith the--pathoption).The important point is that $PATH works basically the same in fish as in other shells and you can use the same techniques to manage it, if you prefer. It's not universal, and you are free to ignore universal variables entirely if you prefer to manage it manually!
That doesn't get your time back but hopefully it helps clear things up for you or the next reader.
krobelus commentedon Apr 19, 2026