5

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.

Argos
  • 53

1 Answers1

7

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 SVN_EDITOR=cat in your preferred environment variable config file (/etc/environment)

Zaroth
  • 467
Ashish K
  • 332
  • 2
    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