Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-config option #7921

merged 7 commits into from May 1, 2021

Add --no-config option #7921

merged 7 commits into from May 1, 2021


Copy link

@faho faho commented Apr 11, 2021


This adds a --no-config option to fish, to let it start up without reading the config.

In particular it will:

  • Keep $fish_function_path set to just the datadir (so /usr/share/fish/functions - just the stuff we ship). No sysconfdir, no vendor directory, nothing else. ($fish_complete_path isn't set at all at the moment)
  • Disable universal variables. If you try to set a universal variable, it will be silently set as a global instead (this is a general change - if fish doesn't manage to set up universal variables, set -U var val is "redirected" to global). They aren't read at all.
  • Disables history by enabling private mode
  • Runs no or conf.d snippets

My hope is that this is basically "independent" of the system entirely. I'm not sure I caught all the places we write something or read something, so anyone else checking is appreciated.

One big issue with this is that it's very uncomfortable interactively because we don't set the colors or set up the handler for $fish_key_bindings. Both of those things happen in __fish_config_interactive, which isn't started.

The bindings can be improved later - {up,down}-or-search shouldn't be functions and then we can just add them to the hardcoded defaults. The colors are tricky because they're usually defined as uvars and we want to allow unsetting a color.

There are a few things we could be doing differently - for instance it would also be possible to do without $fish_function_path entirely, by leaving it unset. This is awkward because fish isn't fully operational without the functions. It's gotten better since e.g. type and eval are no longer functions, but psub still is.

Fixes #1256
Rerun of #5417, #5416
Helps with #5394.


  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.rst

This loads *no* config, *at all*. Not even share/, so
$fish_function_path is entirely unset.
Otherwise `set -U foo bar` if uvars aren't available would simply not
set *anything*.
This only uses the functions fish ships with, but still doesn't allow
any *customization*, which is the point of no-config.

This makes it a lot more usable, given that the actual normal prompt
and things are there.

This still doesn't set any colors, because we don't run
__fish_config_interactive because we don't read (any, because that would run the snippets.
Otherwise this'll error with --no-config
This stops it from saving history.
This was defined in

Just define it here again, it's trivial.
Copy link
Member Author

faho commented May 1, 2021

Alright, I'm merging this now to get more testing, and because the biggest thing (key bindings aren't set) is probably best solved by adding the $fish_key_bindings variable handling to C++, and that's a good PR on its own.

Imagine this as a preview - I think we're on the right track, but the specifics may need hashing out.

@faho faho merged commit 1908cf9 into fish-shell:master May 1, 2021
Copy link

will creating scripts by "#!/bin/fish --no-config", be the preferred way now if you want to create predictable scripts for say setup/install or similar.

Copy link
Member Author

faho commented May 26, 2021

@robfordww Basically not. The issue is that you can't guarantee fish's path (and it most likely will not be /bin/fish, but either /usr/bin/fish or /usr/local/bin/fish), so you would have to use

#!/usr/bin/env fish

and on linux at least the shebang can only have one argument - #!/usr/bin/env fish --no-config would pass fish --no-config to env as one argument, so it would then try to execute a file called fish --no-config. Which probably doesn't exist. (technically not even /usr/bin/env has to exist but I have zero sympathy for platforms that don't have it, and they're not ones you're likely to use)

If you can guarantee fish's path, then sure, go ahead. If not you'd either need a pre-processing step or a wrapper sh-script to execute fish --no-config. But really we need #5394.

@faho faho deleted the no-config-2 branch May 26, 2021 11:02
Copy link

robfordww commented May 28, 2021

@faho Thanks. I was not aware of the "one-argument" thing in #!
I guess:
#!/bin/env -S fish --no-config
has some issues then I am not aware of then?

Copy link
Member Author

faho commented May 28, 2021

env -S has two issues:

  1. You need to know about it and remember to use it
  2. It's a GNU extension

So if you can guarantee your script will only ever be run on GNU systems, have at it. It's just not a solution for us and needlessly narrows the platforms your script can run on. Also it's an ugly hack.

Copy link

Just for the record, FreeBSD added the -S flag to env in version 6.0 (released in 2007), and macOS inherited that. That still leaves a number of platforms in the lurch, of course, starting with OpenBSD and Solaris …

Copy link

While waiting for a prettier recipe, the env -S option seems like a reasonably portable approach. Linux and Mac OS I would guess is 95% of fish's relevant market.

@branchvincent branchvincent mentioned this pull request Jul 27, 2021
3 tasks
faho added a commit to faho/fish-shell that referenced this pull request Nov 25, 2021
The fallback bindings are super awkward to use.

This was called out specifically in fish-shell#7921, I'm going for the targeted
fix for now.
@faho faho mentioned this pull request Nov 25, 2021
3 tasks
faho added a commit that referenced this pull request Mar 17, 2022
* Turn on default bindings for --no-config mode

The fallback bindings are super awkward to use.

This was called out specifically in #7921, I'm going for the targeted
fix for now.

* Only change keybindings when interactive

That's also when we'd source them normally.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging this pull request may close these issues.

Add support for disabling configuration
3 participants