Jump to content

Talk:Environment variables

From ArchWiki

env var editor?

Does anybody know of a little utility that makes it easy to add/remove/modify frequently-modified env vars? e.g. sometimes I want to define one of several LD_LIBRARY_PATH values for my own purposes, or set CXXFLAGS/CFLAGS with some platform-specific optimizations, or change my path to either use icecream or don't use it. So I was thinking a little ncurses utility that turns my favorite frequently-toggled env var choices into a set of checkboxes would be handy to save typing.

—This unsigned comment is by Ecloud (talk) 15:29, 6 December 2016‎. Please sign your posts with ~~~~!

CentOS and similar commonly use Environment Modules for this purpose, though it is far from little. -- Lahwaacz (talk) 16:50, 6 December 2016 (UTC)Reply
I know this post is ancient but I would like to know whether or not there is, after ten years, a utility that the OP talked about in the first post. If not, is there by chance an Env Var verification app to use to determine if your code is correct or not? Ideally it would even tell you how to fix things if you get them wrong.
I'm quite unsure sometimes if my Env Vars are setup correctly -- despite reading relevant pages here over the years off and on when I go to set them up or change them). MoonSwan (talk) 17:28, 22 June 2025 (UTC)Reply

Errata for fish implementation of .env with exports.

Long fish story short: set export (envsubst < .env)

In more detail, regarding the below section of this wiki page:

``` One method for sharing environment variables between different shells is to create a file without any comments, blank lines, or spaces (bash) that can be read directly by envsubst (inspired by [1]):

.env
EDITOR=vim
XDG_CACHE_HOME=$HOME/.cache
XDG_CONFIG_HOME=$HOME/.config
XDG_DATA_HOME=$HOME/.local/share
XDG_STATE_HOME=$HOME/.local/state
~/.bashrc
export $(envsubst < .env)
~/.config/fish/config.fish
set export (envsubst < .env)

```

The above solution for bash worked for me but for fish it didn't. On my machine what worked for fish is this line:


export (envsubst < .env)


In the original code, `set ` is extraneous and needs to be deleted.

Happy to make my first contribution to Arch and I hope it really is a contribution. At least on my machine, it is. Charliemb (talk) 19:45, 15 June 2025 (UTC)Reply

Thanks for this. I wasn't sure about how to export that .env file itself. MoonSwan (talk) 17:31, 22 June 2025 (UTC)Reply
I've updated my scripts further from my previous post. Now, instead of using
`export (envsubst < .env)`
I now use
`export (envsubst < $HOME/.env)`.
Using $HOME/.env has the advantage that if a terminal is opened anywhere other than the home direcotry, .env will be found. Otherwise it won't be found. Charliemb (talk) 01:31, 23 June 2025 (UTC)Reply