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
Currently, we set a few universal variables on first run:
The colors - $fish_color_* and $fish_pager_color_*
$fish_key_bindings
$__fish_initialized
$__fish_initialized is used to guard
Setting the colors (as an optimization)
Upgrading the abbrs from fish 2.3.0
The optimization, on my system, is worth a whopping 0.25 milliseconds, to be paid on each startup of an interactive shell, and in turn updating the defaults becomes harder as we can't tell a user's customization from our old value anymore.
I am not sure updating the abbrs still works (it's two upgrade steps! Once to 2.3.0 and once to 3.0), and I don't have a system to test. I would actually assume most people use abbr calls in config.fish anyway, and even if they don't calling abbr again isn't too odious.
If these two are gone, $__fish_initialized can just go away entirely.
$fish_key_bindings is possibly more acceptable as a universal variable, given that it is a user choice that is quite unlikely to change between shell instances, but given that this is the last default universal variable I believe that behavior to be too surprising, especially since it necessitates actively switching back if the user decides they don't like vi-bindings.
Going further, it would also be possible to always default to global variables even e.g. for fish_add_path and abbr.
(Personally, I'd be open to removing uvars entirely, but I suspect that's not a popular position)
Reacted by Christian Ciach, Balthild and Dixon Sean Low Yan Feng
Removing uvars entirely is an interesting idea. That would fundamentally push fish away from the generally CLI-based configuration it has to a more traditional file-based one. There are quite a few advantages to doing it the file-based way. For example, new users often struggle with the fish paradigm when coming from a traditional shell like bash or zsh. It would also be easier to share configs like people do their .zshrc etc. I'm personally open to the idea, but it would represent a monumental shift for fish.
Reacted by Firegem, landerlo, Daniel Vlčko, Christian Ciach, Isaac de Andrade and David Moberg
Less stuff the user doesn't know or care about in the uvar file
Easier updating of color defaults - if they're uvars, you only ever get the defaults the first time. If they're global, when we change the defaults they apply on next start (but since we would only set the variable if it isn't set, all you need to do to opt out is to set the variable explicitly)
Once we stop setting uvars by default it becomes possible to just ignore uvars entirely
The case for removing uvars entirely is essentially that I don't feel they're worth the complexity - a lot of questions we get would be easier to answer if uvars didn't exist, and in turn they don't help a lot
Reacted by Ilan Cosman, Christian Ciach and David Moberg
What would happen to fish_config - which currently sets uvars?
Probably we'd have to change it use set instead of set -U to prevent shadowing.
The instant color change in all shells would be lost either way, which is something other shells can't do.
I guess we could make the colors special variables, with default values defined in C++, then we can update the defaults, too.
Though that's probably too much magic.
uvars appear convenient, but I agree they add a lot of complexity and potential for confusion.
The instant color change in all shells would be lost either way, which is something other shells can't do.
Yeah, but if this is the only use we can think of, I don't think they justify a feature which could be emulated with a web-based preview feature on the fish_config page.
Since it's a user-facing breaking change, waiting until 4.0 to completely axe uvars seems prudent.
IMO, good qualities of uvars are instant propagation and persistence. I hope we can keep those features. Bad qualities are:
Don't play nice with dotfiles. Users put set -U... into dotfiles, which is a reasonable mistake, because that's how one configures a shell. And you can't easily put your uvar file in source control either.
Variable scope confusion. It's not always clear when you're setting a uvar vs a global. Shadowing is confusing and the interaction between imported env vars and uvars is particularly ugly.
uvar changes may occur at ambiguous times, along with any --on-variable events; this is annoying to implement, and to test.
My skeleton proposal is to replace uvars with a new command varsave, like funcsave. This saves a variable into an expressly human-editable file or file section (may or may not be config.fish) by writing fish code into it: set -g varname varvalue...
Other instances would re-evaluate that file or section when it changes, but only in interactive shells waiting at their prompts. fish itself would never call varsave except as part of fish_config.
This would eliminate the universal variable scope: it would just be globals getting set in a dotfile, very familiar. I think that gets rid of all of the bad parts of uvars, while keeping the fish magic.
Reacted by David Adam, Fabian Boehm, Johannes Altmanninger, Ilan Cosman, Soumya, nfbyte, Patrick Fong, Nils K, blt-r, S L and 7 more
Reacted by Johannes Altmanninger, Soumya, Mauro Toffanin, Nils K, S L, Wuelner Martínez, John Lyon-Smith and Slava
My skeleton proposal is to replace uvars with a new command varsave, like funcsave
Having an explicit synchronization point is a brilliant idea and already makes config.fish work nicer.
So the replacement for set -U foo bar is set -g foo bar; varsave foo?
Also this obviously implies varrm, so I'm not sure it shouldn't be set --sync varname... (no values allowed so people don't try set --sync foo bar in config.fish).
However, this would make it hard to make variables sync from config.fish - how do you create a synced variable? Maybe have set --sync sync if it doesn't exist and set --sync-now sync changes?
This saves a variable into an expressly human-editable file or file section (may or may not be config.fish) by writing fish code into it: set -g varname varvalue...
The obvious tricky bit there is updating the statement, also I don't think we've ever altered the user's config.fish. I'd stick with the explicit file, and I'd also pick a different format, to make it clear it's not full code, to keep it machine-editable.
So, what we should do here is to:
Remove the current default universal variables (probably in 3.3, depending on how soon we're going to release 3.2 - there's some tricky upgrade-related questions)
Open a new issue to discuss a replacement/evolution for uvars.
I don't have too much to add, but since C's are being R'ed
2. Variable scope confusion...
Yes. As a new-ish user, seeing -g, -gx-U all do similar but nuanced things makes things "a bit too much fun" sometimes.
My skeleton proposal is to replace uvars with a new command varsave, like funcsave. This saves a variable into an expressly human-editable file or file section (may or may not be config.fish) by writing fish code into it: set -g varname varvalue...
I think varsave is pretty reasonable. It preserves I don't want to mess with editing a file for this, and I don't really care if I forget about it flexibility I've come to enjoy with Fish.
Also, I'd rather not see the variables written in config.fish. I like the separation between "what I do" and "what the system does" in Fish. Having a file filled up with a bunch of stuff I need to navigate around just so I can add a few lines at the bottom would subtract "magic" for sure.
Additionally anytime you have something automatically adding content to a file that a user can also edit, you can get into a possible clunky stuff like
#####
DO/DO NOT EDIT THIS BLOCK
#####
in the middle of a file with user created content before/after it. Sure it still works, but lacks "style points" 😉
I think we should move this discussion about removing all universal variables to a new issue. This issue is for removing the default ones, and should be closed if and when that happens. I have created a new issue: #7379
Reacted by Fabian Boehm, LastContinue, Geoff MacIntosh and Wuelner Martínez
Activity
IlanCosman commentedon Sep 7, 2020
Removing uvars entirely is an interesting idea. That would fundamentally push fish away from the generally CLI-based configuration it has to a more traditional file-based one. There are quite a few advantages to doing it the file-based way. For example, new users often struggle with the fish paradigm when coming from a traditional shell like bash or zsh. It would also be easier to share configs like people do their .zshrc etc. I'm personally open to the idea, but it would represent a monumental shift for fish.
zanchey commentedon Sep 26, 2020
I'm not clear what the benefit is, though?
Dropping the colour optimisation seems fine as a first action.
faho commentedon Sep 26, 2020
The benefit of removing default uvars?
The case for removing uvars entirely is essentially that I don't feel they're worth the complexity - a lot of questions we get would be easier to answer if uvars didn't exist, and in turn they don't help a lot
krobelus commentedon Sep 26, 2020
What would happen to
fish_config- which currently sets uvars?Probably we'd have to change it use
setinstead ofset -Uto prevent shadowing.The instant color change in all shells would be lost either way, which is something other shells can't do.
I guess we could make the colors special variables, with default values defined in C++, then we can update the defaults, too.
Though that's probably too much magic.
uvars appear convenient, but I agree they add a lot of complexity and potential for confusion.
mattgreen commentedon Sep 29, 2020
IMO, dropping uvars is a good idea.
Yeah, but if this is the only use we can think of, I don't think they justify a feature which could be emulated with a web-based preview feature on the
fish_configpage.Since it's a user-facing breaking change, waiting until 4.0 to completely axe uvars seems prudent.
ridiculousfish commentedon Sep 30, 2020
IMO, good qualities of uvars are instant propagation and persistence. I hope we can keep those features. Bad qualities are:
Don't play nice with dotfiles. Users put
set -U...into dotfiles, which is a reasonable mistake, because that's how one configures a shell. And you can't easily put your uvar file in source control either.Variable scope confusion. It's not always clear when you're setting a uvar vs a global. Shadowing is confusing and the interaction between imported env vars and uvars is particularly ugly.
uvar changes may occur at ambiguous times, along with any --on-variable events; this is annoying to implement, and to test.
My skeleton proposal is to replace uvars with a new command
varsave, likefuncsave. This saves a variable into an expressly human-editable file or file section (may or may not beconfig.fish) by writing fish code into it:set -g varname varvalue...Other instances would re-evaluate that file or section when it changes, but only in interactive shells waiting at their prompts. fish itself would never call
varsaveexcept as part offish_config.This would eliminate the universal variable scope: it would just be globals getting set in a dotfile, very familiar. I think that gets rid of all of the bad parts of uvars, while keeping the fish magic.
faho commentedon Sep 30, 2020
I agree with your diagnosis.
Having an explicit synchronization point is a brilliant idea and already makes config.fish work nicer.
So the replacement for
set -U foo barisset -g foo bar; varsave foo?Also this obviously implies
varrm, so I'm not sure it shouldn't beset --sync varname...(no values allowed so people don't tryset --sync foo barin config.fish).However, this would make it hard to make variables sync from config.fish - how do you create a synced variable? Maybe have
set --syncsync if it doesn't exist andset --sync-nowsync changes?The obvious tricky bit there is updating the statement, also I don't think we've ever altered the user's config.fish. I'd stick with the explicit file, and I'd also pick a different format, to make it clear it's not full code, to keep it machine-editable.
So, what we should do here is to:
LastContinue commentedon Oct 3, 2020
I don't have too much to add, but since C's are being R'ed
Yes. As a new-ish user, seeing
-g,-gx-Uall do similar but nuanced things makes things "a bit too much fun" sometimes.I think
varsaveis pretty reasonable. It preservesI don't want to mess with editing a file for this, and I don't really care if I forget about itflexibility I've come to enjoy with Fish.Also, I'd rather not see the variables written in
config.fish. I like the separation between "what I do" and "what the system does" in Fish. Having a file filled up with a bunch of stuff I need to navigate around just so I can add a few lines at the bottom would subtract "magic" for sure.Additionally anytime you have something automatically adding content to a file that a user can also edit, you can get into a possible clunky stuff like
in the middle of a file with user created content before/after it. Sure it still works, but lacks "style points" 😉
LastContinue commentedon Oct 5, 2020
I'm guessing that a possible removal of
Universalwould also affect abbreviations as well? Would that also then follow the same scheme?abbr -ag foo bar; <command to persist abbrs> foo?IlanCosman commentedon Oct 5, 2020
I think we should move this discussion about removing all universal variables to a new issue. This issue is for removing the default ones, and should be closed if and when that happens. I have created a new issue: #7379
4 remaining items
Switch default universal variables to globals
Switch default universal variables to globals
Switch default universal variables to globals
Switch default universal variables to globals
Collapse universal scope into global scope
Switch default universal variables to globals
Collapse universal scope into global scope
Use globals for color variables, react to dark/light mode
Use globals for color variables, react to dark/light mode
Use globals for color variables, react to dark/light mode
Use globals for color variables, react to light/dark mode
Use globals for color variables, react to light/dark mode