iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🦔
Fish shell: 'set -U' does not create environment variables
Conclusion
set -U only makes it persistent.
Use set -Ux.
set -U makes fish variables persistent, and adding -x seems to export them as environment variables.
# Example: Standard editor settings
set -Ux EDITOR=nano
For $PATH
set -U to modify fish_user_paths seems to be the best practice.
# Example: Adding ~/bin to $PATH
set -U fish_user_paths ~/bin $fish_user_paths
How to check environment variables
- Check if it's in the output of the
printenvcommand. - Look at
~/.config/fish/fish_variablesto see if it'sSETUVAR --export.
How I noticed
I noticed this when EDITOR variable was set but sometimes worked and sometimes didn't, prompting me to investigate.
Specifically, the Ranger command wasn't working.
When I checked the environment variables using the methods above, the EDITOR variable was incorrect.
After setting it correctly, the Ranger command started functioning normally.
Discussion
追記
PATHについて
今はfish_add_path関数を使ったほうが楽ですよ