This question already has an answer here:

When I'm using the svn client in my bash I have to set first the variable SVN_EDITOR like this:

export SVN_EDITOR=cat

So I thought it'd be easier for my if I set the environment variable at startup. I'm using Archlinux, so I referred to the ArchWiki, but there I found out there are multiples ways to set variables.

  • Editing ~/.bashrc
  • Editing ~/.config/systemd.user.conf
  • Using systemctl --user set-environment
  • Editing ~/.profile
  • Editing ~/.pam_environment
  • Editing ~/.bash_profile
  • And even some more.

I'm the only user, so I don't care if the variable is set globally or per user.

Of all the ways to do it, what's the best? What's the "new standard"?

I'm using an up-to-date Archlinux with Gnome and budgie desktop.

Thank you very much.

EDIT: As @jasonwryan said, the question is similar to How do I set a user environment variable? (permanently, not session)

But I'm also asking for what's the most "correct" way to do this, also I'm not sure if there's any new standard since that question (5 years ago). And for some things, Archlinux is quite special, not sure if there was any specific way to do this in it.

marked as duplicate by jasonwryan, GAD3R, countermode, Tim Kennedy, G-Man Mar 28 '17 at 17:06

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Edit the .bashrc file and save the changes, after which source it . <path-to-bashrc> for the changes to take effect for the current terminal. – sai sasanka Mar 28 '17 at 8:24
  • 1
  • The only thing that I can see that differentiates this question from the older one is that this one asks for the best method — which makes it opinion-based. – G-Man Nov 8 '17 at 21:03

In case of ArchLinux, the following files should be used for defining global environment variables on your system - /etc/environment, /etc/profile and shell specific configuration files.

Each of these files has different limitations, so you should carefully select the appropriate one for yourself. Mentioning a few use-cases:

  • /etc/environment - is used by the pam_env module and is shell agnostic so scripting or glob expansion cannot be used. The file only accepts variable=value pairs
  • /etc/profile - initializes variables for login shells only.

In your case, just put export SVN_EDITOR=cat in your preferred environment variable config file (/etc/environment)

  • 1
    the export in /etc/environment is unnecessary, and as a shell command, slightly confusing, since as you said, the file isn't interpreted as a shell script. Though pam_env skips the export keyword, so in itself it's not a problem. – ilkkachu Mar 28 '17 at 13:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.