Hello,
how can I create environment variables based on a configuration file to access via the DV inline JavaScript code? I want to create links to files based on an environment variable, that I can set by hand. I use the following code, which works:
Are you planning to only use these “environment variables” inside Obsidian? If so, could you just have an Environment note with dataview fields and use them through dataview(js) as [[MyEnvironmentNote]].myField? That will avoid causing side-effects on your computer that might confuse other programs (like messing with environment variables that they want, or believe are empty).
If you’re using these environment variables somewhere else (e.g. a Python program), you could use that tool’s method for setting variables, which is probably right near the documentation you’d already be looking at for reading those variables.
Yeah, I plan to use them inside Obsidian. Instead of HOME, I want something like BASEPATH=/Users/Username/Seafile/, so I can make the location dependent on my Cloud storage path of the specific device I’m using. That should not cause any side effects.
Problematic is I don’t know how to define those variables to be readable by JavaScript inside Obsidian. For example with Python, I can just define them in my current shell, and when I run the script it knows those variables. This seems not to be the case for JS and Obsidian.