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

に公開1

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

  1. Check if it's in the output of the printenv command.
  2. Look at ~/.config/fish/fish_variables to see if it's SETUVAR --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

subasuba

追記

PATHについて

今はfish_add_path関数を使ったほうが楽ですよ