Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Atom Editor

20 thoughts
last posted Nov. 22, 2014, 12:43 a.m.

19 earlier thoughts

0

I've been frustrated with the lack of per-window environment variables. It renders my Go workflow nearly impossible.

In my most recent attempt to fix it, I discovered the init.coffee hook. This runs after each window is loaded. Perfect!

Take a look at my first stab at CoffeeScript to solve my problem:

fs = require("fs")
path = require("path")
fs.readFile path.join(atom.project.getPath(), ".atom-env"), "utf8", (err, data) ->
if data?
for line in data.split "\n"
if line != ""
pair = line.split "="
key = pair[0]
value = pair[1]
if value.indexOf "." == 0
value = path.normalize (path.join atom.project.getPath(), value)
process.env[key] = value
view raw init.coffee hosted with ❤ by GitHub

This reads a file in the project directory and sets the environment. I added a quick hack for resolving relative paths inside the project.

Works like a charm!