1

We can export variables from the command line with set -x, but I'd like to know how to do this from within a file. The reason is that I'm organizing my $HOME directory according to the XDG convention, and the Arch wiki says this about zsh:

Consider exporting ZDOTDIR=$HOME/.config/zsh in ~/.zshenv. You could also add this to /etc/zsh/zshenv.

I want to effect an export from /etc/zsh/zshenv to avoid cluttering my $HOME. Can I simply input the Fish Shell command set -x from within this file or is there an alternative?

Thanks

12
  • 2
    why would the fish shell read your /etc/zsh/zshenv? fish is not zsh! Dec 6, 2021 at 16:01
  • I want to prevent the dot file from being created in my home directory. I don't have zsh, but Cargo is creating ~/.zshenv. I was hoping to prevent that.
    – Pound Hash
    Dec 6, 2021 at 16:15
  • what does Cargo have to do with fish? and what with zsh? Really confused now! Dec 6, 2021 at 16:17
  • Fish is my shell. So I use it to manage my system's environment variables. If I'm told to modify an environment variable, then I think to use my shell to do that.
    – Pound Hash
    Dec 6, 2021 at 16:19
  • 3
    I must really be missing something. Could you edit your question to explain your full motivation, starting from what you're doing, what causes cargo to create some files you can't have (and why you can't have them), to what environment variables you want to export for which purpose. This all so far has made zero sense to me :( Dec 6, 2021 at 16:25

1 Answer 1

3

Have you read about fish's config files? Configuration files

If you want to set up an environment variable for Cargo, you can:

  • create a universal variable once: set -Ux VARIABLE=value
  • add an entry into $HOME/.config/fish/config.fish: set -gx VARIABLE=VALUE
  • create a file in $HOME/.config/fish/conf.d/, say cargo.fish that contains that set -gx line.

I would avoid adding app-specific env.vars into "global" rc files (e.g. /etc/fish/config.fish) -- keep your own settings in your own configuration files.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .