7 ms·
OK so if you're new to fish you should understand universal variables since it's a concept that bash/zsh does not have and it's actually pretty great. When peo
by bin_bash 3y ago
OK so if you're new to fish you should understand universal variables since it's a concept that bash/zsh does not have and it's actually pretty great.
When people first try out fish they want to add their global env vars and PATH configuration to ~/.config/fish/config.fish. You can absolutely do this similar to how you do it in ~/.bashrc. However, it's not idiomatic and once you get used to universal variables, you'll see that it's a lot of yak shaving you really just don't need editing config.fish.
Instead, if you want to permanently set an env var across the current session and all new sessions, run: `set -Ux MY_ENV_VAR 1` (set a universal variable, and export it to subprocesses)
That will put it into a machine-readable file ~/.config/fish/fish_variables. You can open it if you want but this way you don't need to source your rc files, open a new shell, or even open your editor.
For PATH, just run: `fish_add_path ~/my-new-bin`. It uses universal variables by default.
For some reason I avoided universal variables as much as possible for years using fish and now I think that was really silly.